Skip to content

sla2pdf-team/sla2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sla2pdf

Convert Scribus SLA documents to PDF, using the command line or Python API. Runs Scribus in a subprocess with a custom Python script.

Installation

sla2pdf may be installed via pip, like any other Python project:

Normal installation (copies a snapshot of the code to a python package directory)

pip install .

Development installation (points to the source tree, so changes take effect without needing to re-install)

pip install -e .

If you have multiple versions of Python 3 installed, any of them may be used to install sla2pdf. It does not necessarily need to be the one Scribus is linked against.

Examples

Command Line

  • Export to PDF, placing outputs in the current directory
sla2pdf file1.sla file2.sla
  • Export files with explicit output paths
sla2pdf file1.sla file2.sla -o out1.pdf out2.pdf
  • Match SLA files by wildcard and export them to the directory out/
sla2pdf *.sla -o out/
  • Export to PDF with parameters

    The parser accepts integers, floats, booleans (case-insensitive), lists, tuples, dictionaries and byte strings in Python syntax. Anything else is interpreted as string. String interpretation may also be enforced with quotes (use \ escaping as necessary).

sla2pdf file1.sla --params compress=true compressmtd=1 quality=2 version=16
  • Export to image
sla2pdf file1.sla file2.sla -c img -o out1/ out2/ --params type=JPG
  • Run multiple tasks, separated by - (avoids re-starting scribus)
sla2pdf file1.sla - file2.sla --params quality=2 - file2.sla -c img out/

Python API

Basic batch conversion usage:

from sla2pdf.runner import batch_convert

pdf_params = dict(
    compressmtd=1,  # JPEG
    quality=2,      # Medium
    version=16,     # PDF 1.6 standard
)
pdf_task = dict(
    inputs=["file1.sla", "file2.sla"],  # input files
    outputs=["out1.pdf", "out2.pdf"],   # output destinations (file paths, or a directory)
    converter="pdf",    # pdf converter
    params=pdf_params,  # custom pdf export parameters
)

img_params = dict(
    dpi=300,  # resultion
    transparentBkgnd=True,  # transparent background
    type="PNG",  # image format
)
img_task = dict(
    inputs=["file3.sla", "file4.sla"],  # input files
    outputs=["out3/", "out4/"],         # output destinations (sequence of directories)
    converter="img",    # image converter
    params=img_params,  # custom image export parameters
),

batch_convert([pdf_task, img_task], hide_gui=True)  # run it

Behaviour

sla2pdf uses lossy image compression by default. Quality settings can be controlled using the --params option.

Development

Relevant Scribus links:

Python 2 Compatibility Notice

Several files show the following notice:

# -- This code needs to remain compatible with Py2 --

That is because the file in question is run inside Scribus (either directly, or indirectly through imports). Some mainstream Scribus distributions are still built with Python 2, so we intend to keep compatibility for the time being.

About

Convert Scribus SLA documents to PDF (CLI or Python API)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages