7

I have a one page PDF file with scanned documents. I need to send only top half of this document to someone. How can I generate a new PDF document with only the top half of the original page, without losing details?

slm
  • 369,824
Grzenio
  • 5,867

5 Answers5

5

How To Print a Selected Portion of a PDF File

Using the native Adobe Acrobat Reader

  1. Make sure the basic toolbar is visible by right clicking on a blank area of the toolbar, and placing a check mark next to Basic if it is not already enabled.

  2. Find the "Snapshot Tool" on the Basic toolbar and select it.

  3. Drag a box around the area you want to print. A message will alert you that the selection has been copied to the clipboard. Click OK and you will see a dashed line around the area you just selected.

  4. Click Print.

  5. In the print dialog, set the print rage to "Selected graphic."

  6. If you want to print the selection at its intended size, set Page Scaling to "None."

  7. If you want the selection to fill the paper, set the page scaling to "Fit to paper." You may need to check the "Auto-Rotate and Center" check box to maximize paper usage.

  8. When you are satisfied with the preview, click OK to print the document.

References

slm
  • 369,824
4

If you only need to do this once and for a single page, I would just open the PDF with GIMP and copy the top half:

gimp 150264785-test-pdf.pdf

That will bring up a screen asking you to chose the pages you want to import:

enter image description here

Import the 1st page, then simply use GIMP to select and cut the region you are interested in, paste it as a new image and export to PDF again.

terdon
  • 242,166
3

That's half of un2up (modulo a rotation). So, with Python and its pyPdf library:

#!/usr/bin/env python
import copy, sys
from pyPdf import PdfFileWriter, PdfFileReader
input = PdfFileReader(sys.stdin)
output = PdfFileWriter()
for p in [input.getPage(i) for i in range(0,input.getNumPages())]:
    (w, h) = p.mediaBox.upperLeft
    p.mediaBox.lowerLeft = (w, h/2)
    output.addPage(p)
output.write(sys.stdout)
0

Using pyPdf 1.13

#!/usr/bin/env python
import copy, sys from pyPdf import PdfFileWriter, PdfFileReader input = PdfFileReader(sys.stdin) output = PdfFileWriter() for p in [input.getPage(i) for i in range(0,input.getNumPages())]: q = copy.copy(p) (w, h) = p.mediaBox.upperRight p.mediaBox.upperRight = (w, h/2) q.mediaBox.lowerRight = (w, h/2) output.addPage(p) output.addPage(q) output.write(sys.stdout)

0

Because pyPdf is abandoned, I updated this to use the PyPDF2 fork which is officially encouraged

This page is no longer updated. I've stopped maintaining pyPdf, and a company named Phaseit has forked the project and continued development and maintenance with my blessing as pyPdf2 ( http://knowah.github.com/PyPDF2/).

Furthermore, since I wanted to wrap it in a shell script I used command-line arguments.

#!env python
import copy, sys
from PyPDF2 import PdfFileWriter, PdfFileReader
input = PdfFileReader(open(sys.argv[1], 'rb'))
output = PdfFileWriter()
for p in [input.getPage(i) for i in range(0, input.getNumPages())]:
    (w, h) = p.mediaBox.upperLeft
    p.mediaBox.lowerLeft = (w, h/2)
    output.addPage(p)
output.write(open(sys.argv[2], 'wb'))