-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_to_pdf.py
More file actions
33 lines (26 loc) · 990 Bytes
/
export_to_pdf.py
File metadata and controls
33 lines (26 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
"""
export_to_pdf.py — Scribus Python script: export the current document to PDF.
Intended to be run by proxy_print.py via Scribus in headless mode:
scribus <document.sla> -g -ns --python-script export_to_pdf.py
The output PDF path is taken from the SCRIBUS_PDF_OUTPUT environment variable.
If not set, it defaults to the same path as the SLA file with a .pdf extension.
"""
import scribus
import os
import sys
if not scribus.haveDoc():
print("export_to_pdf.py: No document is open.", file=sys.stderr)
sys.exit(1)
doc_path = scribus.getDocName()
pdf_path = os.environ.get("SCRIBUS_PDF_OUTPUT",
os.path.splitext(doc_path)[0] + ".pdf")
print(f"export_to_pdf.py: Exporting '{doc_path}' -> '{pdf_path}'")
try:
pdf = scribus.PDFfile()
pdf.file = pdf_path
pdf.save()
print("export_to_pdf.py: Export complete.")
except Exception as e:
print(f"export_to_pdf.py: ERROR: {e}", file=sys.stderr)
sys.exit(1)