14

I would like to do some basic editing on existing PDF file. More specifically:

  • Add chapters/bookmarks
  • Change page numbering

However, I cannot find any tool, GUI or command line, which would offer this functionality. Is there any free-open alternative tools?

18

I use pdftk mainly. But here are some others to consider:

pdfsam (PDF Split and Merge): "pdfsam is an open source tool (GPL license) designed to handle pdf files"

PDFJam "A small collection of shell scripts which provide a simple interface to much of the functionality of the excellent pdfpages PDF file package (by Andreas Matthias) for pdfLaTeX." (You can also use pdfLaTeX directly.)

jPDFTweak: "jPDF Tweak is a Java Swing application that can combine, split, rotate, reorder, watermark, encrypt, sign, and otherwise tweak PDF files."

Inkscape: is a vector graphics editor that can both import PDF pages into its native SVG format, and also export as PDF.

Calibre: Open source ebook management software that can convert PDFs to other formats, and manipulate them in other ways. Comes with command line tools such as pdfmanipulate which can be useful.

Ghostscript of course can do a lot of things with PDF files too.

  • I use pdfjam but it seems none will do the 2 things I explicitly listed. – Maciej Piechotka Oct 21 '10 at 19:56
  • 2
    I misunderstood the question. Edit the question to make it clear what you meant by "chapters". I assumed you just wanted to insert one part of a PDF inside another. But perhaps you mean the pdf bookmarks (i.e., which appear in the side pane for some viewers)? PDFJam might not, but the pdfpages package for PDFLaTeX, along with the LaTeX hyperref package, can handle those. pdfedit should be able to change page numbers. With pdfLaTeX/pdfpages you could clip the bottom of the page and add new ones. BRISS can crop off headers/footers too, but you'd have to add them back with something else. – frabjous Oct 21 '10 at 20:18
  • Oh, and mbPDFasm can apparently also do stuff with bookmarks, but I've never used it: thierry.schmit.free.fr/spip/spip.php?article15&lang=en – frabjous Oct 21 '10 at 20:24
  • 2
    Another: jPDFBookmarks: flavianopetrocchi.blogspot.com/2009/03/… – frabjous Oct 21 '10 at 20:27
12

I know two programs for manipulating PDFs under Linux:

PDEedit "PDFedit is a free open source pdf editor and a library for manipulating PDF documents, released under terms of GNU GPL version 2. It includes PDF manipulating library based on xpdf, GUI, set of command line tools and a pdf editor."

and pdftk "If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents."

  • pdfedit: I don't have qt3 and I cannot install it (not in portage) & I cannot get it to compile with qt4 (even with qt3support). – Maciej Piechotka Oct 21 '10 at 19:36
4

The only way I found to add page numbers to a PDF was with LaTeX:

Create a file /usr/local/bin/add-page-numbers.tex

\documentclass[8pt]{article}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}

\topmargin 70pt
\oddsidemargin 150pt

\pagestyle{fancy}
\rfoot{\Large\thepage}
\cfoot{}
\renewcommand {\headrulewidth}{0pt}
\renewcommand {\footrulewidth}{0pt}

\begin{document}
\includepdfset{pagecommand=\thispagestyle{fancy}}
\includepdf[pages=-]{input.pdf}
\end{document}

And a file /usr/local/bin/pdf-numbers

#!/bin/bash
name="${1%\.pdf}-numbers"
wd="$(pwd)"
dir=/tmp/pdf-numbers
mkdir -p "$dir"
cp "$1" "$dir/input.pdf"
cd "$dir"
pdflatex --jobname "$name" /usr/local/bin/add-page-numbers.tex > /dev/null
mv "$name.pdf" "$wd"
rm -r "$dir"

Make the latter file executable, and run it with

    pdf-numbers example.pdf

It will create a pdf file called example-numbers.pdf (and overwrite it if it already exists!).

  • Working very well. Imperfection lies in absolute paths, but that's nothing I couldn't manage. However, could you elaborate how did u added these numbers and how change positions of numbers? – kravemir Jan 16 '15 at 9:48
2

pdfimport for openoffice is a good alternative to edit PDF documents and re-export to PDF or save to another format. The imported PDF can be edited with OpenOffice Draw.

1

latex with the pdfpages packages can do most of these things.

Specifically on how to add bookmarks, see http://michaelgoerz.net/blog/2011/04/pdf-bookmarks-with-latex/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.