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:
First page of PDF after processing without -dFixedMedia
:
First page of PDF after processing WITH -dFixedMedia
:
Update:
Here is a link to this one page PDF file: PDF-File
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With