1 # -*- coding: utf-8 -*-
4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
8 # Full author contact details are available in file CREDITS
10 # This script takes a PS or PDF file and creates a low resolution version.
12 # convert_pdf.py big.pdf small.pdf ebook
14 # This script takes three arguments:
15 # INFILE: the name of the .ps or .pdf file to be converted.
16 # OUTFILE: the name of the .pdf file to be created.
17 # PDFSETTINGS: any PDFSETTINGS supported by ghostscript:
22 from lyxpreview_tools import error, find_exe_or_terminate, run_command
26 return "Usage: %s <ps or pdf input file> <pdf output file> <screen|ebook|printer|prepress>" \
39 gs = find_exe_or_terminate(["gswin32c", "gswin64c", "gs"])
40 gs_call = '%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite ' \
41 '-dCompatibilityLevel=1.4 -dPDFSETTINGS=/%s ' \
42 '-sOutputFile="%s" "%s"' % (gs, pdfsettings, output, source)
44 gs_status, gs_stdout = run_command(gs_call)
46 sys.stdout.write(gs_stdout)
50 if __name__ == "__main__":
51 sys.exit(main(sys.argv))