How to add page numbers to Postscript/PDF

前端 未结 14 1882
臣服心动
臣服心动 2020-12-07 12:06

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

14条回答
  •  执念已碎
    2020-12-07 12:17

    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}
    

提交回复
热议问题