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.

3
  • Why don't you use a small bash-script or a makefile? Then the number of steps are irrelevant. Commented Jul 9, 2011 at 9:40
  • @Marco: The above steps are extracted from my batch file. :-) You can see there are %1 placeholders that represent the file name without extension. Commented Jul 9, 2011 at 9:46
  • Ah ok. I thought it was an example ;-) Commented Jul 9, 2011 at 9:50

1 Answer 1

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.

2
  • As pdfcrop executes pdftex internally, do we need to pass -interaction=nonstopmode to pdfcrop? Commented Jul 9, 2011 at 17:46
  • No. Not necessary.
    – Lev Bishop
    Commented Jul 9, 2011 at 20:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .