Renumber pages of a PDF

I want to edit the metadata of a scanned PDF to assign custom page numbers to different pages. For example, what are now pages 1-3 I might want to call i, ii and iii, and what are pages 4-10, I want to call 1-7. I do not want to change the actual order of the pages.

Is there A) A way to do this at all using free tools; and B) A way to do this "in batch" (so, without having to renumber each page manually).


Solution 1:

Here a solution based on LaTeX. It uses the pdfpages package to include the scanned PDF (here called scan.pdf). The PDF page labels you want can be set using the hyperref package with the pdfpagelabels option enabled. It uses the normal \thepage macro as a label which can be defined to lower case roman numbers. The page counter is then reset and changed back to normal numbers.

\documentclass[a4paper]{article}% or use 'letterpaper'
\usepackage{pdfpages}
\usepackage[pdfpagelabels]{hyperref}
\begin{document}
% Set lower case roman numbers (\Roman would be upper case):
\renewcommand{\thepage}{\roman{page}}
\includepdf[pages=1-3]{scan.pdf}
% Back to normal (arabic) numbers:
\renewcommand{\thepage}{\arabic{page}}
% Reset page counter to 1:
\setcounter{page}{1}
\includepdf[pages=4-]{scan.pdf}
\end{document}

Place the above code into a file (e.g. scan_mod.tex) and compile it with pdflatex:

# pdflatex scan_mod

This will produce scan_mod.pdf. However any special annotations incl. hyperlinks will disappear. This shouldn't be any problem with scanned PDFs.

If you need this more often you could write a script which accepts the number of roman numbered pages and the file name(s) as arguments and creates a tempfile with the above code where the name and numbers are variables, which is then compiled.

Solution 2:

You can do that with a text editor.

  • metadata - How to change internal page numbers in the meta data of a PDF? - Super User

As the answer says, open a PDF file with a text editor, search /Catalog entry, and then append an entry named /PageLabels like this:

/PageLabels << /Nums [
0 << /P (cover) >> % labels 1st page with the string "cover"
1 << /S /r >> % numbers pages 2-6 in small roman numerals
6 << /S /D >> % numbers pages 7-x in decimal arabic numerals
]
>>

Note that the page indices (physical page numbers) begin with 0.

Of cource, you can do this automatically using scripting languages.

PDF Standards - Page Labels has detailed specification.

Solution 3:

jPDF Tweak is an Open Source graphical utility that offers page numbering (the correct term is "page labeling") and many other beginner to advanced PDF editing features. It runs on Ubuntu and other operating systems.

The Documentation page provides step-by-step instructions.

Solution 4:

There is a little python script, that can do the job: https://github.com/lovasoa/pagelabels-py

In your case call:

./addpagelabels.py --delete file.pdf
./addpagelabels.py --startpage 1 --type 'roman lowercase' file.pdf
./addpagelabels.py --startpage 4 --type arabic file.pdf

Solution 5:

There's a tool called PDF Mod which is a free tool to rearrange the pages of a PDF.

It can be installed from the Ubuntu Software Centre in Ubuntu 10.10 and higher.

To install in Ubuntu 9.10 or 10.04 :

To install Add the ppa ppa:pdfmod-team/ppa to your software sources (Here's how to do that) and install pdfmod from the software center

Adapted from : http://www.webupd8.org/2011/03/edit-pdf-documents-in-linux-with-pdf.html

Good Luck :D