Quick Reference on often used Ghostscript PDF options

Convert PostScript to PDF

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -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 PDF document

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

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 with color preserving — 300 dpi images)
-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 the specified 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

PDFmarks:

Create a file named "pdfmarks" with this content:

[ /Title (Document title)
  /Author (Author name)
  /Subject (Subject description)
  /Keywords (comma, separated, keywords)
  /ModDate (D:20061204092842)
  /CreationDate (D:20061204092842)
  /Creator (application name or creator note)
  /Producer (PDF producer name or note)
  /DOCINFO pdfmark

then combine it with a PostScript or PDF file:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=withmarks.pdf \
    nomarks.ps pdfmarks

or add a couple of named destinations to the pdfmarks file:

[ /Dest /NamedDest1 /Page 1 /View [/XYZ 20 620 1.8] /DEST pdfmark
[ /Dest /NamedDest2 /Page 2 /View [/FitH 15] /DEST pdfmark

or bookmarks:

[/Count -2 /Dest /NamedDest1 /Title (Preface) /OUT pdfmark
[ /Action /GoTo /Dest /NamedDest1 /Title (Audience) /OUT pdfmark
[ /Action /GoTo /Dest /NamedDest2 /Title (Content) /OUT pdfmark
[/Count 3 /Page 2 /View [/XYZ 10 160 1.0] /Title (Part 1) /OUT pdfmark
[ /Page 2 /View [/XYZ 10 160 1.0] /Title (A first one) /OUT pdfmark
[ /Page 3 /View [/XYZ 0 500 NULL] /Title (The second one) /OUT pdfmark
[ /Page 6 /View [/FitH 220] /Title (The third thing) /OUT pdfmark
[ /PageMode /UseOutlines /DOCVIEW pdfmark

For more information about pdfmarks see pdfmark Reference Manual.

Note for LyX, LaTex/teTeX and Tex users:

To be able to embed Type1 Computer Modern fonts into the resulting pdf file you will need CM-Super, the GPL licensed Type1 Computer Modern font package, in addition to the TeX default Computer Modern METAFONT-based fonts. Most GNU/Linux distributions already provide the cm-super package — for easy installation use the distributions default package management system.