tags:

views:

621

answers:

5

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

EDIT: Moved my solution down into an 'answer'

+2  A: 

Maybe pstops (part of psutils) can be used for this?

Filip Korling
I've spent quite a bit of time on it, and it seems like psutils won't do it - unless I'm missing something.
Brian M. Hunt
+1  A: 

Oh, it's a long time since I used postscript, but a quick dip into the blue book will tell you :) www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF

On the other hand, Adobe Acrobat and a bit of javascript would also do wonders ;)

Alternatively, I did find this: http://www.ghostscript.com/pipermail/gs-devel/2005-May/006956.html, which seems to fit the bill (I didn't try it)

brinxmat
+5  A: 

This might be a solution:

  1. convert postscript to pdf using ps2pdf
  2. create a LaTeX file and insert the pages using the pdfpages package (\includepdf)
  3. use pagecommand={\thispagestyle{plain}} or something from the fancyhdr package in the arguments of \includepdf
  4. if postscript output is required, convert the pdflatex output back to postscript via pdf2ps
rcs
I think this is a great idea, but it I haven't got it working. The page numbers don't insert *over* the \includepdf pages.
Brian M. Hunt
Have you used something like `\includepdf[pages=-,pagecommand={\thispagestyle{plain}}]{document.pdf}`?
rcs
Got it working - posted solution in the question.
Brian M. Hunt
+1  A: 

I am assuming you are looking for a PS-based solution. There is no page-level operator in PS that will allow you to do this. You need to add a footer-sort of thingy in the PageSetup section for each page. Any scripting language should be able to help you along.

dirkgently
Brian M. Hunt
+1  A: 

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 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}

This works.

Brian M. Hunt