Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prohibit rotation of pages in PDF when using Ghostscript

I'm using GhostScript to change DPI and resize PDF-files from PHP using exec() function. My commandline code looks like this:

gs  -o out.pdf  -sDEVICE=pdfwrite  -dDEVICEWIDTHPOINTS=800 -dDEVICEHEIGHTPOINTS=1000 -dPDFFitPage -dPDFSETTINGS=/ebook in.pdf

But one of my PDFs first page after this processing is rotated and cropped. If I add -dFixedMedia parameter it will be still rotated but not cropped. But some other pages will be rotated in this case.

I've also tried -dOrient1=false and -dOrient1=true... and -dAutoRotatePages=/None... It all didn't work... Maybe I'm not using it right...

Is it possible to prevent/prohibit any kind of rotation for all PDF-pages?


P.S.

First page of initial PDF:

Initial

First page of PDF after processing without -dFixedMedia: After1

First page of PDF after processing WITH -dFixedMedia: After2


Update:

Here is a link to this one page PDF file: PDF-File


like image 265
Pigalev Pavel Avatar asked Apr 15 '13 00:04

Pigalev Pavel


1 Answers

Its not really possible to tell what's going on without seeing an example file. Normaally pdfwrite will preserve the various boxes from the input file, and especially the MediaBox.

If it was me, I would start by removing -dPDFSETTINGS from the command line, this sets a lot of options. I'd set the options I wanted individually. Note that because you have this last in the command line, it will potentially override any prior settings.

If you set AutoRotatePages to false, then pdfwrite doesn't attempt any kind of rotation of the output.

like image 191
KenS Avatar answered Nov 09 '22 09:11

KenS