How to resize a PDF’s pages

pdf

I got a PDF file for which I want to change its pages' sizes; let's call it file.pdf. And I got another PDF file which will serve as the model to file.pdf; let's call it model.pdf.

To clarify: I want file.pdf's pages to be of equal measure as model.pdf's pages.

Using pdfinfo on model.pdf I get the following relevant info:

Tagged:         no
Form:           none
Pages:          22
Encrypted:      no
Page size:      612 x 783 pts
Page rot:       0
MediaBox:           0.00     0.00   720.00   891.00
CropBox:           54.00    54.00   666.00   837.00
BleedBox:          54.00    54.00   666.00   837.00
TrimBox:           54.00    54.00   666.00   837.00
ArtBox:            54.00    54.00   666.00   837.00
File size:      3324788 bytes
Optimized:      no
PDF version:    1.7

I don't really understand what the first two columns of the *Box fields mean, but doing some Googling I got to the conclusion that my target are the last two columns of the MediaBox field. So, I want file.pdf to be 720x891, and I think the units are pts.

So I found this tool called pdfposter which is supposed to be able to change the size of a PDF's pages, and I did this (noteice I already made the conversion from points to inches):

pdfposter -m10x12.375inch file.pdf new_file.pdf

Everything goes well, but when I check new_file.pdf with pdfinfo I get:

Tagged:         no
Form:           none
Pages:          32
Encrypted:      no
Page size:      630.22 x 891 pts
Page rot:       0
MediaBox:          54.33    32.60   774.33   923.60
CropBox:           54.33    32.60   684.55   923.60
BleedBox:          54.33    32.60   684.55   923.60
TrimBox:           54.33    32.60   630.22   891.00
ArtBox:            54.33    32.60   630.22   891.00
File size:      3005203 bytes
Optimized:      no
PDF version:    1.3

Clearly something went wrong since the size of the new PDF's pages is 774.33x923.60 and not 720x891; moreover, the first two columns of the MediaBox changed from 0.00 0.00 to 54.33 32.60 and I got no idea why or what it means.

I also tried using pdfjam but it just adds more white space to the borders, while leaving the content of the PDF untouched.

So my question is: how can I change the size of my file.pdf's pages to that of model.pdf.

Note: It is very important for me that the resized PDF be of the same quality as the original PDF.

Best Answer

You can use pdfjam with the --papersize argument to set the output paper size. You may also need to use --scale and --offset if you want to do more than resize the page and its contents together.

pdfjam --papersize="$(LC_ALL=C pdfinfo model.pdf | awk '/^Page size:/ {printf "{%fbp,%fbp}", $3, $5}')" file.pdf new_file.pdf
Related Question