Manipulate PDFs with gostscript

By | June 28, 2015

Basic Usage
Convert PostScript to PDF:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=fileout.pdf filein.ps

Merge/combine PDF and/or PostScript files:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=fileout.pdf \
filein.ps filein2.pdf

Extract a page from a PostScript or a PDF document:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=3 -dLastPage=3 \
-sOutputFile=fileout.pdf filein.ps

Additional Options
PDF optimization level selection options

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)

Paper size selection options

-sPAPERSIZE=letter
-sPAPERSIZE=a4
-dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h (point=1/72 of an inch)
-dFIXEDMEDIA (force paper size over the PostScript defined size)

Other options

-dEmbedAllFonts=true
-dSubsetFonts=false
-dFirstPage=pagenumber
-dLastPage=pagenumber
-dAutoRotatePages=/PageByPage
-dAutoRotatePages=/All
-dAutoRotatePages=/None
-r1200 (resolution for pattern fills and fonts converted to bitmaps)
-sPDFPassword=password
-dCompatibilityLevel=

Advertisements