2

I am using TeXLive 2010 and do my job using the following workflow with 6 steps. I want to reduce the number of steps as minimal as possible because I will apply the workflow to the web based system.

  1. latex %1
  2. dvips %1
  3. ps2pdf -dPDFSETTINGS#/prepress %1.ps
  4. gswin32c -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dSAFER -dNOPAUSE -dQUIET -dBATCH -sOutputFile=%1-temp.pdf %1.pdf
  5. pdfcrop --hires %1-temp.pdf %1.pdf
  6. pdftops -eps %1.pdf

I know that the steps 3, 4 and 5 internally invoke GhostScript. Shortly speaking, how to combine them into a single GhostScript call?

My current effort

I have tried to combine the step 3 and 4 as follows and it works.

  1. latex %1
  2. dvips %1
  3. ps2pdf -dCompatibilityLevel=1.5 -dPDFSETTINGS#/prepress %1.ps
  4. rename %1.pdf %1-temp.pdf
  5. pdfcrop --hires %1-temp.pdf %1.pdf
  6. pdftops -eps %1.pdf

And I am still interested in combining steps 3 and 5 above.

Display Name
  • 46,933

1 Answers1

1

You can't combine steps 3 and 5. Steps 3&4 use -sDEVICE=pdfwrite so they can combine. Step 5 uses -sDEVICE=bbox to find the bbox. You need separate runs of gs to use separate devices.

You can eliminate your revised step 4 with the rename %1.pdf %1-temp.pdf by making step 3 as ps2pdf -dCompatibilityLevel#1.5 -dPDFSETTINGS#/prepress %1.ps %1-temp.pdf. By the way I needed to change = to # for -dCompatibilityLevel#1.5.

It's not worth trying to optimize this further. If you are planning to run this on a web system on user-supplied code then be aware of all the security risks. You better add -R to dvips, and be aware that pdfcrop executes pdftex internally (pdfcrop --restricted helps a little) and so on.

Lev Bishop
  • 45,462