tavinus / pdfScale

Bash Script to Scale and Resize PDFs using Ghostscript
MIT License
246 stars 37 forks source link

Add an auto scale option #24

Closed yarrouye closed 1 year ago

yarrouye commented 3 years ago

If -s auto is used, pdfScale.sh will compute the scale itself. This is useful when one wants to print a PDF onto a different media than its indicated media size, while keeping the dimensions of its content the same on the new media. While this can often be achieved simply by printing, some platforms, e.g., Chrome OS, lack the ability to center a PDF when printing it, making double sided printed of centered content (e.g., for cutting a booklet) impossible without transforming the PDF before printing.

In scale mode, the default scale of 0.95 is used.

In mixed mode, the scale will be computed to be the ratio of the input's page size divided by the output's resized page size. The width and height ratios are both computed and the minium of the two is used as the scale. If the resulting scale would be bigger than 1 (100% of the resized page), it is limited to 1.

tavinus commented 3 years ago

I got a bit confused by this.

So the idea is to resize the paper and keep the contents size (real size in milimeters for example)?

I still need to test this.

yarrouye commented 3 years ago

Yes, that's the idea. An example is https://czechgames.com/files/rules/under-falling-skies-pnp-rules-en.pdf which is smaller than the paper available in my country (US Letter). I use a Chromebook, and when printing there is no way to keep the size true while centering the contents, which is needed if printing two-sided. Resizing the paper but keeping the content true to size (and centering it, which is the default behavior) allows to produce a file that then will print well double sided.

tavinus commented 1 year ago

Can you confirm the original default behavior is not changed? That if you run it without any options it will scale down 5%? I still need to test it running though.
Going through the code, it seems fine.