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?

6
  • 1
    Probably not what you want but via acrobat reader: graphicssoft.about.com/od/adobe/ht/printportionpdf.htm
    – slm
    Oct 21, 2013 at 13:44
  • What utility are you using to view the PDF?
    – phemmer
    Oct 21, 2013 at 14:03
  • I was actually using acrobat reader among others, and the way @sim proposed did the job! I will accept your answer, if you create one.
    – Grzenio
    Oct 21, 2013 at 14:16
  • OK I'll write it up
    – slm
    Oct 21, 2013 at 14:19
  • Done making it an answer.
    – slm
    Oct 21, 2013 at 14:22

5 Answers 5

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

5
  • I can't find a snapshot tool in evince. Are these instructions for okular? Oct 21, 2013 at 16:23
  • @Gilles - thanks, they are for Adobe Reader, I've added a comment at the top about this.
    – slm
    Oct 21, 2013 at 16:32
  • @Gilles - incidentally I stopped looking for alternatives after the OP said he was using Adobe Reader, but another way would probably a good add to this Q just for completeness if you know of one.
    – slm
    Oct 21, 2013 at 16:35
  • I basically did that two years ago — just needs a little tweak. Oct 21, 2013 at 16:46
  • @Gilles - you have a time machine, don't you?
    – slm
    Oct 21, 2013 at 16:49
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.

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'))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .