How can I programmatically renumber pages in a PDF?

6

As a graduate student, I come across PDFs of articles and book chapters on a daily basis. Sometimes these PDFs are paginated correctly internally (that is, if an article starts on page 67, the PDF starts on page 67 as well; not on page 1). When they aren't, I have to open the file in Acrobat and renumber the pages in the "Page Thumbnails" panel.

I would love to be able to automate this whole process with a script (bash, Python, AppleScript, whatever) that lets me pass the first actual page number... something like fixpagination example.pdf 67. However, I cannot find any terminal-based program that can re-paginate PDFs. Neither pdftk nor PyPDF seem to be able to deal with pagination.

Are there any scriptable programs that can internally re-paginate PDF files?

Andrew

Posted 2013-05-08T01:38:25.577

Reputation: 1 869

Answers

1

You might want to check out this Q&A.

Glutanimate

Posted 2013-05-08T01:38:25.577

Reputation: 314

Ooh. That looks promising. (And a little terrifying, editing the PDF directly like that.) I'll play around with this… – Andrew – 2013-05-08T18:50:22.773

Hrm. It seems to be more complicated than it initially looks: http://stackoverflow.com/a/12925195/120898

– Andrew – 2013-05-08T19:15:04.070

0

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  --firstpagenum 67 file.pdf

DG'

Posted 2013-05-08T01:38:25.577

Reputation: 329