Is there a command or script that would help me ease the process of adding page numbers to a pdf with hundreds of pages? Thanks.


Using LaTeX!

0) Install LaTeX if necessary

1) In the following latex document replace x.pdf by your file.pdf




\fancyhead[LO]{Lecture notes of askubuntu}

  \includepdf[pagecommand={\thispagestyle{empty}},pages=1 ]{x.pdf}


3) run pdflatex addfooter.tex and a addfooter.pdf will be created.

4) adapt the headers, footer (left,center, right), tune margin's sizes, etc.


Although LaTeX version give us more control over the details, as @steeldriver, pointed out, in some situations a pdfjam command line is the best choice. Typical use:

pdfjam --outfile newfile.pdf --pagecommand '{}' oldfile.pdf
  • 3
    The pdfjam package provides a possibly more convenient interface to Latex's pdfpages functionality e.g. pdfjam --outfile newfile.pdf --pagecommand '{}' oldfile.pdf – steeldriver Dec 23 '15 at 13:47
  • 1
    @steeldriver, thank you! pdfjam is always a good idea, but in this case I believe we will need to tune several details, (define margins, page size, header and footer details, and probably some unnumbered pages, etc) – user216043 Dec 24 '15 at 0:13
  • 1
    thx, that helped me. can someone maybe give a hint on how to move the output of --pagecommand to the top, or more in general where can i find documentation about what is possible with --pagecommand? maybe bold text or colors are interesting too. thx in advance! – divramod Mar 14 at 10:43

I actually found a much better solution myself. Rather than doing it manually as suggested above, and wasting time on figuring it out, the easiest way is to simply install jpdftweak package. It does this and more with a couple of mouse clicks. Enjoy!

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.