Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add page numbers to Postscript/PDF

Tags:

pdf

postscript

If you've got a large document (500 pages+) in Postscript and want to add page numbers, does anyone know how to do this?

like image 511
Brian M. Hunt Avatar asked Oct 21 '09 20:10

Brian M. Hunt


People also ask

How do I insert page numbers in power PDF?

From the menu bar choose Edit > Headers, Footers, Page Numbers > Insert. The Header, Footer, Page Number dialog opens. From the Position menu, choose whether to put the page numbers at the top of the page in the header, or at the bottom of the page in the footer. Check the Page Numbering box to add page numbers.

How do I add page numbers to a PDF in 2021?

Select the "Header & Footer" in the Edit PDF Toolbar, and click on the "Add..." option from the drop-down menu. When the Add Header and Footer dialog box appears, place your cursor in the location where you want to insert the page number. Step 3. Then click on the Page Number and Date Format button.

How do I add page numbers to a PDF in Google Drive?

How to add page numbers in a PDF document in Google Docs automatically? If you don't want any specific formatting on your page numbers, then you can choose to add and update them automatically. Here's how: Once your PDF document is converted, click on 'Insert' and select 'Header & page number'.


2 Answers

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} 
like image 109
Brian M. Hunt Avatar answered Sep 23 '22 07:09

Brian M. Hunt


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) 
like image 31
Dingo Avatar answered Sep 20 '22 07:09

Dingo