Magnifying PDFs

I'm posting magnifypdf-llncs in case it's useful for other people. When it's run as magnifypdf-llncs input.pdf > output.pdf, it converts an LNCS-format input.pdf with pages like this into an output.pdf with pages like this.

Variants of the script that expect slightly different input formats: magnifypdf-ams; magnifypdf-ams2.

Internally, these are built on top of a more general script magnifypdf that, along with the input filename, takes a magnification factor, a number of pt to move left, and a number of pt to move down. See comments in the magnifypdf-* scripts for examples of how to calculate these numbers (and notes on what's safe for printers, in case you're printing or providing a document for people who might be printing). The calculations could be automated starting from bbox information; I'm not sure I want a slightly overfull page to shrink everything, but it would probably be good to avoid having bboxes go outside the visible (or printable) area.

magnifypdf, in turn, is built on top of pypdf from Mathieu Fenniak et al. Most of the work in magnifypdf is handled by pypdf, in particular by pypdf's clone_from, which copies pages and metadata, and by pypdf's add_transformation, which stretches and shifts the text on each page. The clone_from option needs a recent version of pypdf. I used pip install pypdf. I haven't audited pypdf; use a VM.

(I had originally written magnifypdf in a more complicated way using pypdf version 2 without clone_from, and that seemed to work with various PDF viewers, but apparently Acrobat Reader refused to display the file.)

Most of the lines in magnifypdf are for also stretching and shifting links (positions in the PDF that you can click on) and destinations (targets of links). I probably missed ways to make this simpler or more robust or both.

Another easy way to modify PDFs is to use the pdfjam package (which is internally built on top of TeX), but that package doesn't preserve links, presumably because \includegraphics doesn't preserve links. Another margin-shrinking option that I haven't tried is Briss.

If you're starting with the TeX source of a paper, you can achieve similar stretching and link preservation with something like \mag 1200 \hoffset -0.8in \voffset -0.5in (depending on the input format), but that doesn't work with LuaLaTeX.

The magnifypdf* scripts are hereby placed into the public domain. SPDX-License-Identifier: LicenseRef-PD-hp OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT.