Changwang Zhang
Changwang Zhang

Reputation: 2483

Ghostscript: How to convert EPS to PDF with the same page size

I want to convert a EPS figure to a PDF figure with the same width and height.

The following command:

gswin32 -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH \
  -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 \
  -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 \
  -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile="test.pdf" \
  -f "test.eps"

only produces a PDF file with the page size of a letter.

Any help would be much appreciated.

Here is the test EPS file: https://dl.dropboxusercontent.com/u/45318932/test.eps

Upvotes: 2

Views: 5289

Answers (2)

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90285

To make KenS' answer more explicit, using the test.eps sample file you linked to... the following command will suffice to do what you want:

gswin32                 \
 -sDEVICE=pdfwrite      \
 -dPDFSETTINGS=/printer \
 -dEPSCrop              \
 -o test.pdf            \
  test.eps

The -o test.pdf is (for not too ancient versions of Ghostscript!) shorthand for -dNOPAUSE -dBATCH -sOutputFile=test.pdf.

Your test.eps uses a font named /SHZENL+Tahoma_00. Ghostscript will automatically embed this font, and it will be a subset by default (the prefix SHZENL may change in the PDF, though).

Here is a screenshot from the page the command from your question created. That page is 612 x 792 pts (letter size):

enter image description here

Here is the screenshot from the page the command given in my answer created. Its page size is 360 x 216 pts:

Result when adding <code>-dEPSCrop</code>

Upvotes: 4

KenS
KenS

Reputation: 31199

EPS files cannot contain a media size request. In the absence of any media size request Ghostscript uses the default.

However.....

From the documentation:

http://www.ghostscript.com/doc/9.15/Use.htm#EPS_parameters

-dEPSCrop : Crop an EPS file to the bounding box. This is useful when converting an EPS file to a bitmap.

Upvotes: 3

Related Questions