views:

311

answers:

2

Hello, am using ghostscript to create pdf file from postscript file. My PS file, doesn't have orientation instructions, so when I want to create landscape pdf file, I'm using ghostscript to rotate the page. The problem is, that ghostscript rotates only the first page, and when my pdf file is more than 1 page, the others, are not rotated correctly. Here is the command I'm using:

cat $psinput | gs -sPAPERSIZE=a4 -sDEVICE=pdfwrite -sOuputFile="/tmp/pdf" \
        -dAutoRotatePages="/None" -c "<< /Orientation 3 >> setpagedevice" \
        90 rotate 0 -595 translate -dNOPAUSE -dEPSCrop  -f - -c -quit

Does anybody have an idea how to correct this?

+1  A: 

Without seeing your actual $psinput it is difficult to give definite advice. Your $psinput, coming via stdin to Ghostscript, could contain multiple PS files... Have you tried playing with one of these options

  • -dOrient1=true
  • -dOrient1=false

in your commandline? Also, it looks to me like you should put your 90 rotate 0 -595 translate command inside the quotes going with -c, and then position the input (-f -) to the very end of processing like so:

  • -c "<</Orientation 3>> setpagedevice 90 rotate 0 -595 translate" -f - -c quit

Also have you tried to use

  • -c ".setpdfwrite <<//AutoRotatePages /PageByPage>> setdistillerparams" or
  • -c ".setpdfwrite <<//AutoRotatePages /All>> setdistillerparams" or
  • -c ".setpdfwrite <<//AutoRotatePages /None>> setdistillerparams"

on your commandline (with or without your original rotating code)?

pipitas
A: 

If you must not use ghostscript to do the rotation, you can probably use pdftk or impose instead.

hlovdal