

So my conclusion is that the hard part is to find a solution that works across the board on different documents with different sizes and orientations. Seems weird that GS would floor those values though. After I started rounding them, they seem to always be the one needed. And that is one of the reasons I always run the scaling after resizing in my script (in mixed mode).Ībout the fraction problems when using the Paper Name, I had that happening to me before I rounded the conversions from mm/inches to points. Because this fits-to-page, the other part of my script may be handy to scale the contents inside the PDF after resizing (specially if the proportion of the PDF changed a lot). Please note that I am also using -dFIXEDMEDIA AND -dPDFFitPage. dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 \ dSubsetFonts=true -dEmbedAllFonts=true \ dColorConversionStrategy=/LeaveColorUnchanged \ dCompatibilityLevel="1.5" -dPDFSETTINGS="/printer" \ q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER \ This is for A4 Portrait size with PageByPage auto-rotation: gs \ This is what I am calling for resizing, changing the variables to real values.

I still could not do it all in a single GS call though. Then I added now the functionality to do one, the other or both. My little app was originally created to scale PDFs (without changing the page size). Using -dAutoRotatePages also seems to reduce the need for pre-flipping the page size, even though it is not the same thing. My script defaults to PageByPage but that is adjustable. -dAutoRotatePages=/PageByPage - auto-rotates pages individually.-dAutoRotatePages=/All - rotates all pages (or none) depending on a kind of "majority decision".-dAutoRotatePages=/None - retains orientation of each page.When I was trying to fix the auto-rotation problem, I found this other Kurt response. Check they have the same orientation or Flip Target if necessary.Get the target's page size in points (Eg.Get Source PDF page sizes (For Flip Detection).So this is how my approach went (in a scripted way) Using -dFIXEDMEDIA seems to be a must on both cases, as pointed out before. I had also already included the GS Paper Sizes in my script (with names and sizes). I was using -dDEVICEWIDTH, -dDEVICEHEIGHT instead of the longer, points version, but they both seem to do the same thing (both get points).īecause my bash script is already capable of getting source page sizes and I liked the idea to be able to set custom page sizes, I decided to focus on setting the page size in points.You can set custom defined papers as well (any size you want really).Not so easy to script around it, as you will need the new page size in points and would also need the source's page sizes if you want to detect landscape/portrait.

Makes sure you get the size you want in points.Set paper size in PS-points -dDEVICEWIDTHPOINTS, -dDEVICEHEIGHTPOINTS May not produce 100% accurate points size.I have played with this for a few days and here is my partial conclusion on the methods posted here: I am using a bit of a mix of Kurt's and Tim's answers. I have this little script called pdfScale which absorbed parts of the answers posted here. First, thanks for everyone that posted here.
