13

I need to shrink some large PDFs to print on an 8.5x11 inch (standard letter) page. Can ImageMagick/Ghostscript handle this sort of thing, or am I having so much trouble because I'm using the wrong tool for the job?

Just relying on the 'shrink to page' option in client-side print dialogs is not an option, as we'd like for this to be easy-to-use for the end users.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
ceejayoz
  • 176,543
  • 40
  • 303
  • 368

5 Answers5

17

I would not use convert. It uses Ghostscript in the background, but is much slower. I'd use Ghostscript directly, since it gives me much more direct control (and also some control over settings which are much more difficult to achieve with convert). And for convert to work for PDF-to-PDF conversion you'll have Ghostscript installed anyway:

  gs \
    -o /path/to/resized.pdf \
    -sDEVICE=pdfwrite \
    -dPDFFitPage \
    -r300x300 \
    -g2550x3300 \
    /path/to/original.pdf
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • 4
    What are `-r300x300` and `-g2550x3300` – theonlygusti Sep 01 '18 at 21:46
  • @theonlygusti: `r` is for resolution in dots per inch (in horizontal and in vertical direction). `g` is for page dimensions in pixels (in horizontal and in vertical direction). You'll want to read [some of the Ghostscript documentation](https://www.ghostscript.com/doc/current/Use.htm) in order to avoid asking such *basic* questions... – Kurt Pfeifle Sep 01 '18 at 22:42
8

The problem with using ImageMagick is that you are converting to a raster image format, increasing file size and decreasing quality for any vector elements on your pages.

Multivalent will retain the vector information of the PDF. Try:

java -cp Multivalent.jar tool.pdf.Impose -dim 1x1 -paper "8.5x11in" myFile.pdf

to create an output file myFile-up.pdf

Dingo
  • 2,619
  • 1
  • 22
  • 32
danio
  • 8,548
  • 6
  • 47
  • 55
  • 4
    Turns out the latest version of this software does not include the pdf tools! You must find and use the Multivalent20060102.jar file. – Joe Koberg Jan 19 '10 at 22:37
  • 1
    here: http://minus.com/lherwk1Y5TQzZ and here: http://ge.tt/6fVll5H you can download the latest Multivalent version **with tools** – Dingo Sep 03 '12 at 08:26
  • 20060102 version seems to also be at http://sourceforge.net/projects/multivalent/files/multivalent/Release%2020060102/ – danio Sep 11 '12 at 09:04
  • New link for multivalent.jar with tools inside: https://rg.to/file/c6bd7f31bf8885bcaa69b50ffab7e355/Multivalent20060102.jar.html – Dingo Mar 28 '21 at 15:18
7

ImageMagick's mogrify/convert commands will indeed do the job. Stephen Page had just about the right idea, but you do need to set the dpi of the file as well, or you won't get the job done.

Assuming you have a file that's 300 dpi and already the same aspect ratio as 8.5 x 11 the command would be:

// 300dpi x 8.5 -2550, 300dpi x 11 -3300
convert original.pdf -density "300" -resize "2550x3300" resized.pdf

If the aspect ratio is different, then you need to do some slightly trickier cropping.

danieltalsky
  • 7,752
  • 5
  • 39
  • 60
6

The Ghostscript approach worked well for me. (I moved my file from my Windows PC to a Linux computer and ran it there.) I made one small change to the Ghostscript command because the Ghostscript resize command above completely fills an 8.5 by 11 inch page. My printer cannot print to the edge, though, so several milllimeters along each page edge were lost. To overcome that problem, I scaled my PDF document to 0.92 of a full 8.5 by 11 inches. That way I saw everything centered on the page and had a slight margin. Because 0.92 * (2550x3300) = (2346x3036), I ran the following Ghostscript command:

  gs -sDEVICE=pdfwrite \
     -dPDFFitPage \
     -r300x300 \
     -g2346x3036 \
     /home/user/path/original.pdf \
     -o /home/user/path/resized.pdf
Jon Ahlquist
  • 61
  • 1
  • 1
0

If you use Insert > Image... in LibreOffice Writer to insert a PDF, you can use direct manipulation or its Image Properties to resize and reposition the PDF, and when you File > Export as... PDF the PDF remains vectors and text. Interestingly when I did this with a PDF invoice the PDF exported from LO is smaller than the original, but the Linux pdfimages command-line utility suggests LO preserves any raster images within the original PDF.

However, you want something easier-to-use for your end users than the print dialog's "Shrink to page" option. There are tools like Adobe Acrobat that lay out PDFs to form print jobs that are PDFs; I don't know which ones have a simple "Change the bounding box and scale to letter-size". Surprisingly the do-it-all qpdf tool lacks this feature.

skierpage
  • 2,514
  • 21
  • 19