Extended Brain Storage

Arch Linux: PDF Modifications

Posted on July 2, 2013

Several notes of how to alter PDF files in Linux...

Prerequisite

The following steps are based on the PDF Toolkit (PDFTK) software. It is a simple tool for doing everyday things with PDF documents. This software may be present in other Linux distributions as well as in UNIX and BSD based operating systems.


Concatenation

Multiple PDF files can be joined as follows:

$ pdftk FILE0.pdf FILE1.pdf FILE2.pdf cat output OUTPUTFILE.pdf

Splitting to Pages

A PDF file can be split into single pages as follows:

$ pdftk INPUT.pdf burst output OUTPUT_%02d.pdf

alternatively:

$ pdftk INPUT.pdf burst output OUTPUT_%02d.pdf compress

Splitting to Selected Range of Pages

As an example, in order to select only pages 2 to 5, the following needs to be done:

$ pdftk SOURCEFILE.pdf cat 2-5 output SELECTED.pdf dont_ask

Rearranging Pages

The order of pages in a PDF file can be arbitrarily changed as follows:

$ pdftk SOURCEFILE.pdf cat 3 1-2 4-end output OUTPUTFILE.pdf

Watermark Injections

A watermark PDF file can be created (e.g. in LibreOffice) and injected as follows:

$ pdftk SOURCEFILE.pdf background HEADER.pdf output OUTPUTFILE-HEADER.pdf

Resizing All Pages

Size of pages within a PDF file can be changed to a different one using GhostScript:

$ gs \
 -o OUTPUTFILE.pdf \
 -sDEVICE=pdfwrite \
 -sPAPERSIZE=a4 \
 -dFIXEDMEDIA \
 -dPDFFitPage \
 -dCompatibilityLevel=1.4 \
SOURCEFILE.pdf

Tags: #Arch Linux #macOS #PDF #PDFTK #gs #GhostScript

⏴ Previous Post Next Post ⏵