user2766123
user2766123

Reputation: 115

ImageMagick - PDF resize without stretching interior content

I have a PDF of size 8.27in × 10.87in, but the printer at my work requires pages be US Letter size (8.5in x 11in). ImageMagick can achieve the resizing with:

convert -page Letter mypdf.pdf mypdf-converted.pdf

The resulting pdf is 8.5x11 and prints out fine, but the text and images in the pdf are stretched. What I want is exact copies of original 8.27x10.87 pages stuck on 8.5x11 pages with no stretching of the interior content. Ideally the content would be centered, but having the content aligned to one side is fine as well.

I've messed with some of the -filter options, but to no avail. Is there an option for what I'm describing?

Also, as a note: I tried printing the file to a PDF in Document Viewer (the default Linux PDF viewer) and adjusting the page settings, but that caused what I think are weird character encoding issues. For some reason I can view the pdf on my computer fine, but the printer prints out lots of "!"s and "%"s and other random characters in place of the text. The resulting PDF from ImageMagick doesn't cause any problems like this.

Thanks!

Upvotes: 1

Views: 2024

Answers (1)

johnwhitington
johnwhitington

Reputation: 2763

You can use our free (for non-commerical use only, see license) Coherent PDF (cpdf) tool:

First, change the size of the pages:

cpdf -mediabox "0 0 8.5in 11in" in.pdf -o out.pdf

Then, shift the contents rightward and upward by half the difference in size:

cpdf -shift "0.115in 0.0515in" out.pdf -o out2.pdf

Or, all together:

cpdf in.pdf -mediabox "0 0 8.5in 11in" AND -shift "0.115in 0.0515in" -o out.pdf

Upvotes: 2

Related Questions