tavinus / pdfScale

Bash Script to Scale and Resize PDFs using Ghostscript
MIT License
242 stars 36 forks source link

Can you resize and fill the page instead of fitting the image? #23

Closed wesbaker closed 3 years ago

wesbaker commented 3 years ago

Right now when I resize a document that has some full bleed pages, I get white bars on the left and right side. Is there any way to have it fill the page and just cut off the top and bottom of the page when resizing?

wesbaker commented 3 years ago

Maybe answering my own question here, but it looks like a resize followed by a scale should do it. Just playing with the scale factor now.

tavinus commented 3 years ago

Resizing preserves the current positioning and proportional size of the content. So, if you had 10% bleed for example, you would continue to have 10% bleed (which would be bigger in size if you increased the paper size). Resize actually uses fit-to-page with the contents.

Scaling would increase/decrease the contents while preserving the paper size.

You can also reposition the contents with other parameters, as described in the help message.
There are many ways to do it. Few possibilities are:

 --hor-align, --horizontal-alignment <left|center|right>
             Where to translate the scaled page
             Default: center
             Options: left, right, center
 --vert-align, --vertical-alignment <top|center|bottom>
             Where to translate the scaled page
             Default: center
             Options: top, bottom, center
 --xoffset, --xtrans-offset <FloatNumber>
             Add/Subtract from the X translation (move left-right)
             Default: 0.0 (zero)
             Options: Positive or negative floating point number
 --yoffset, --ytrans-offset <FloatNumber>
             Add/Subtract from the Y translation (move top-bottom)
             Default: 0.0 (zero)
             Options: Positive or negative floating point number

Not sure how you did it, but you can do everything in a single call (resize + scale).

Cheers!
Gus

wesbaker commented 3 years ago

I just ended up combining -s 1.01 -r letter and that did exactly what I wanted.

tavinus commented 3 years ago

Some PDFs also have a Cropbox that is not the same as the MediaBox, which can cause some problems.

You can tune those with

 -c, --cropbox <paper>
             Resets Cropboxes on all pages to a specific paper size
             Only applies to resize mode
             <paper> can be: full | fullsize - Uses the same size as the main paper/mediabox
                             custom          - Define a custom cropbox size in inches, mm or points
                             std paper name  - Uses a paper size name (eg. a4, letter, etc)