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