letter-size pages scanned to PDF as legal size. How can I "trim" off the top?

89 views Asked by At

We have 22 pages of legal documents that were originally on letter size paper. The originals were lost in a fire. The lawyer's office has a PDF with scans of the originals but the scan was done with "legal" size. Is there any way to redo the PDF and have it only use the "letter size" portion of each page?
I've look at pdftk and magick and haven't seen any options that will do this. My best guess is to explode the 22 page3 PDF to 22 separate graphic files, resize them using Paint.net, then create a new PDF using pdftk. I know how to do all that except the "export PDF page as graphic image" part.

screen capture

Update 18-Jan-24 : I'm unable to include a copy of the original document because it contains PII. Both of the answers below are good. I used the 2nd one as it was easier.

2

There are 2 answers

1
fmw42 On BEST ANSWER

You have posted an image that is already in letter size (612x792pixels). If you really have a PDF in legal format, please post the actual PDF. If that is the case, likely you can do the following in Imagemagick.

convert -density 72 image.pdf -gravity south -crop 612x792+0+0 +repage result.pdf

ADDITION

The above works, but since I cannot post the PDF or a zip of it directly, I have used

convert -density 72 image.pdf -gravity south -crop 612x792+0+0 +repage result.png

enter image description here

Or whatever output suffix that you want.

Always best to provide the version of IM that you use and your OS.

1
K J On

This is probably one of the easiest of all PDF fixes, so straight forward it would be fastest to do by hand. However, since most OS no longer include a basic HeX editor (Why? It was so darn useful and essential, in early Operating Systems) you need to use a binary tool like HxD.

Windows Portable Download (Same English or French Version)

For MacOS Mark Setchell recommends HexFiend or via Github Also for Universal Xross platforms in any browser he has recommended HexEd.it which aims to work in offline mode without file transmittal and has "Find aNd Replace" function see lower right in this image.

enter image description here

Copy the Legal.pdf into a working file called Letter.pdf

Open the Letter.PDF and "search" for /Media using "Search all". A good idea is first check if there is any /CropBox entry as that would be better and use that in preference. If you can't find either see problem section at end of answer.

enter image description here

There should be 22 "hits" so double click first one and it should show /MediaBox[0 0 612 1008] . we need to on the right OVERWRITE the 1008 into 792 with a space to not disturb file size or contents.

enter image description here

Ensure you never use delete keys or the length will change here is an example

enter image description here

you could do the same 22 times but there is a find and replace function so use that carefully. ensure you use some characters either side to avoid corrupting any other 1008 that is not the same and ensure the text length is identical (with a space after 792).

enter image description here

the whole job will be done faster than I can describe it.

enter image description here

Save with a different name if necessary to preserve the original, but you should only be using a duplicate working copy.

Potential problems:

  • The file has neither /Crop nor /MediaBox, this is possible with encoded or encrypted files. You will need to decide how to decompress the file with or without a password. That is a totally separate question.
  • The value is not a simple 1008, say it is 1007.987, then simply match the overall number of digits thus 792.0000 (trailing zeros is not a problem).
  • The value varies a lot for the 22 entries, well you may find a few the same. So with luck just have to run a number of replacements for each value, hopefully not all 22 vary!