How to add page numbers to Postscript/PDF

Based on rcs's proposed solution, I did the following:

Converted the document to example.pdf and ran pdflatex addpages, where addpages.tex reads:

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

\topmargin 70pt
\oddsidemargin 70pt

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

\begin{document}
\includepdfset{pagecommand=\thispagestyle{fancy}}
\includepdf[fitpaper=true,scale=0.98,pages=-]{example.pdf}
% fitpaper & scale aren't always necessary - depends on the paper being submitted.
\end{document}

or alternatively, for two-sided pages (i.e. with the page number consistently on the outside):

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

\topmargin 70pt
\oddsidemargin 150pt
\evensidemargin -40pt

\pagestyle{fancy}
\fancyhead{} 
\fancyfoot{} 
\fancyfoot[LE,RO]{\Large\thepage}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}
\includepdfset{pages=-,pagecommand=\thispagestyle{fancy}}
\includepdf{target.pdf}
\end{document}

Easy way to change header margins:

% set margins for headers, won't shrink included pdfs
% you can remove the topmargin/oddsidemargin/evensidemargin lines
\usepackage[margin=1in,includehead,includefoot]{geometry}

you can simply use

pspdftool

  • http://sourceforge.net/projects/pspdftool

in this way:

pspdftool 'number(x=-1pt,y=-1pt,start=1,size=10)' input.pdf output.pdf

see these two examples (unnumbered and numbered pdf with pspdftool)

unnumbered pdf

http://ge.tt/7ctUFfj2

numbered pdf

http://ge.tt/7ctUFfj2

with this as the first command-line argument:

number(start=1, size=40, x=297.5 pt, y=10 pt)