2
1
I'd like to run a script to do some PDF manipulation in Scribus non-interactively, but I can't find documentation to say definitely whether this is possible, and if so, how.
2
1
I'd like to run a script to do some PDF manipulation in Scribus non-interactively, but I can't find documentation to say definitely whether this is possible, and if so, how.
5
This is possible, but you need the "non-stable" Scribus >= 1.5.1 (this is a development version - to anyone in the future, use the stable Scribus >= 1.6 when its out) to start Scribus with a script.
I had to compile this from source on Debian.
Additionally scribus's --no-gui option doesn't actually seem to work (as of 1.5.2), so I use xvfb-run
to hide it "off screen".
I use &> /dev/null
to pipe away all the debugging information printed to stderr, which is too noisy to be useful. But you'll want to turn that off when getting your script to work initially.
sudo apt-get install xvfb
xvfb-run scribus --no-gui --no-splash -py scribus2pdf.py -o OUTPUT.pdf -- INPUT.sla &> /dev/null
Note this is a proposed syntax working with Scribus 1.5.2 only. You might have to format the arguments for the python script differently on other versions of Scribus. Note also that Scribus uses Python 2, not 3.
Note files saved in Scribus 1.5 are NOT backwards compatible with Scribus 1.4
Here's my scribus2pdf.py
# Requires Scribus >= 1.5.1
# Tested on Scribus 1.5.2
# Usage:
# scribus --no-gui --no-splash -py scribus2pdf.py -o OUTPUT.pdf -- INPUT.sla &> /dev/null
# To hide the gui properly, prefix the above with xvfb-run
import sys
import getopt
import scribus
try:
opts, args = getopt.getopt(sys.argv[1:],"o:")
except getopt.GetoptError as e:
print(e)
sys.exit(1)
for opt, arg in opts:
if opt == "-o":
dest = arg
if not dest: sys.exit(1)
if scribus.haveDoc() :
pdf = scribus.PDFfile()
pdf.file = dest
pdf.save()
else:
print("Expected input")
sys.exit(1)
0
Currently that is only possible via the Python startup script. Scribus will still start the UI, so on a headless server you need to install Xvfb or Xdummy.