abarker / pdfCropMargins

pdfCropMargins -- a program to crop the margins of PDF files
Other
361 stars 35 forks source link

Bottom not cropped as expected on certain PDFs #27

Closed madamadami closed 4 years ago

madamadami commented 4 years ago

I got one-page PDFs of websites where the bottom margin can't be cropped with pdfCropMargins (I tried different calculation methods without success). Further investigation and testing revealed, that the bottom-margin is partially shrinked: the more whitespace at the bottom in the original PDF, the larger the remaining margin in the cropped PDF — it's seems like the original margin is shrinked percentually. For reproduction, I attached the original and cropped files in two versions: one with a huge white bottom margin and one with a smaller white bottom margin respectively. Hope this issue can be fixed.

(Notice: this PDF-cropper https://github.com/ho-tex/pdfcrop removes the bottom margins flawlessly.)

Test-PDF_less_whitespace_cropped.pdf Test-PDF_less_whitespace_original.pdf Test-PDF_cropped.pdf Test-PDF_original.pdf

abarker commented 4 years ago

What arguments are you using to invoke pdfCropMargins? By default it leaves 10% of the existing margin (unlike some programs, which crop the entire margin by default). You can set the percentage value for all margins using the -p option, or for each margin individually by using the -p4 option. Running the program like this works for me to remove all the margins (retaining 0%):

pdf-crop-margins -p 0 Test-PDF_original.pdf

There are lots of other, related options, too. Run pdf-crop-margins -h | more to see them (or look at the bottom of the main github README page).

madamadami commented 4 years ago

Thank you! I was used to these other programs and missed the default behavior completely. Now it works very well!