PDF Hacks

Mort Yao

1 How to edit a PDF document (losslessly)

There are many ways to edit a PDF document. This one is the best operable solution I know, as it requires only open-source software and preserves text and fonts data in the original document.

Tools needed:

  • Poppler, PDF rendering library distributed with many useful command-line utilities for handling PDF contents
  • Inkscape, the SVG editor

1.1 Step 1. Split the PDF document into single-page PDFs

$ pdfseparate foo.pdf 'foo%d.pdf'

1.2 Step 2. Convert single-page PDF to SVG (to edit)

Suppose the page to edit is foo1.pdf:

$ inkscape --without-gui --file=foo1.pdf --export-plain-svg=foo1.svg

Or:

$ pdftocairo -svg foo1.pdf foo1.svg

1.3 Step 3. Edit the SVG

With Inkscape. Whatever you like.

1.4 Step 4. Convert SVG back to PDF

$ inkscape --without-gui --file=foo1.svg --export-pdf=foo1.pdf

1.5 Step 5. Join single-page PDFs into one PDF document

$ pdfunite foo1.pdf foo2.pdf ... bar.pdf