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?
How to print half of a page to a pdf file
pdfprinting
Related Solutions
Using Xournal you can annotate PDFs and add custom images (e.g. a transparent PNG). Although it is used for taking freehand notes and drawing, it can also annotate PDFs.
On Ubuntu:
- Install Xournal through the Ubuntu Software Center
- Open Xournal
- Select "Annotate PDF" from the File menu and select your PDF file to be signed.
- Click the "Image" button in the toolbar (it looks like a silhouette of a person).
- Click on document. A file browser dialog will open.
- Select a PNG image of your signature.
- Resize and position the image on the PDF.
- Select "Export to PDF" from the File menu.
More info at http://www.howtogeek.com/215485/sign-pdf-documents-without-printing-and-scanning-them-from-any-device/
Here is how I would remove the OCR-ed text should I have to...
First, you need to know, that OCR-ed text in a PDF is not a layer, but a special text rendering mode. The following screenshot from the official PDF specification lists all available text rendering modes:
For more background, please see these answers of mine on StackOverflow:
Now for the procedure I envisage:
0. Make a backup of your original PDF file
'nuff said...
1. Use qpdf
to un-compress most of the PDF objects
qpdf
is a beautiful command line tool to transform most PDFs into a form that makes it easier to manipulate through a text editor (or through sed
):
qpdf \
--qdf \
--object-streams=disable \
input.pdf \
editable.pdf
2. Search for spots where PDF code contains 3 Tr
All spots in the editable.pdf
where there is 'invisible' (a.k.a. neither filled nor stroked) text is marked by an initial definition of
3 Tr
Change these to now read
1 Tr
This should make the previously hidden text visible. Glyphs will appear in thick outlines, overlaying the original scanned page images.
It will look very ugly.
Save the edited PDF.
3. Change Tj
and TJ
text stroking operators to 'no-ops'
Whenever a text string is prepared for being rendered, the actual operator that is responsible for doing so is named Tj
or TJ
.
Look out for all of these. Replace them by tJ
and tj
. This will change them into 'no-ops': they have no meaning at all in the PDF source code; no PDF viewer or processor will "understand" them. (Be careful not to change the number of bytes when replacing stuff in PDF source code, because otherwise you may cause it to become "corrupted".)
Save the PDF file.
4. Check how the PDF file looks now
The PDF should now look "clean" again. The renamed text operators do not have any meaning any more for the PDF viewer, nor for any PDF interpreter.
5. Use Ghostscript to create the final PDF
This command should achieve what you want:
gs \
-o final.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
editable.pdf
This final step uses editable.pdf
as input. It outputs final.pdf
. The output will have removed all traces of text. The input still had the text, albeit in an "unusable" form, because the operator renaming. Since Ghostscript does not "understand" the re-named operators, it will simply skip them by default.
Best Answer
How To Print a Selected Portion of a PDF File
Using the native Adobe Acrobat Reader
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.
Find the "Snapshot Tool" on the Basic toolbar and select it.
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.
Click Print.
In the print dialog, set the print rage to "Selected graphic."
If you want to print the selection at its intended size, set Page Scaling to "None."
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.
When you are satisfied with the preview, click OK to print the document.
References