TransWikia.com

How add header and footer to all pdf in a folder

TeX - LaTeX Asked by Monsoon Malabar on May 26, 2021

I have following file called addfooter.tex to add header and footer in a pdf file.

documentclass{article}
RequirePackage[a4paper,top=2cm,left=2cm,right=2cm,bottom=1.5cm]{geometry}

usepackage{url}
usepackage{hyperref}
usepackage{lmodern}
usepackage{pdfpages}
usepackage{fancyhdr}
begin{document}
setcounter{page}{1}

fancyfoot[RO]{url{https://mydomain.com}}
fancyfoot[LO]{url{https://www.facebook.com/mydomain}}
fancyfoot[CO]{thepage}

fancyhead[LO]{url{http://bit.ly/mydomain}}
fancyhead[RO]{url{https://test.mydomain.com}


  includepdf[pagecommand={thispagestyle{empty}},pages=1]{ee.pdf}
  includepdf[pagecommand={thispagestyle{fancy}},pages=2-]{ee.pdf}

end{document}

This will create a file called addfooter.pdf with required header and footer. But I need to add header and footer to all my file in a folder. How to do it using a shell script or something like that?
I am using pdflatex command.

One Answer

  • Use usepackage rather than RequirePackage, the latter is intended for package and class files
  • Make sure hyperref comes last of loaded packages.
  • You are missing a } in fancyhead[RO]{url{https://test.mydomain.com}.

Following code should work:

documentclass{article}
usepackage{fancyhdr}
usepackage{pdfpages}
usepackage{hyperref}
fancyhf{}
fancyhead[LO]{url{http://bit.ly/mydomain}}
fancyhead[RO]{url{https://test.mydomain.com}}

fancyfoot[RO]{url{https://mydomain.com}}
fancyfoot[LO]{url{https://www.facebook.com/mydomain}}
fancyfoot[CO]{thepage}

begin{document}
includepdf[pages=1-, pagecommand={thispagestyle{fancy}}]{example.pdf}
end{document}

Answered by ZhiyuanLck on May 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP