1

Say I have a bunch of Word documents, PowerPoint and Excel files. I have some cover photo.

I want to convert the files to PDF, add the cover photo and footer to the bottom of each page hello world

Could it be automated in LaTeX? I want to run it on a Windows server.

I can convert the files to PDF using a Python script. I guess I can do everything using Python but I don't trust Python for more than conversion, manipulating files is better done in LaTeX I guess.

  • What footnotes? In general, you can use the pdfpages package to include existing PDFs into a LaTeX document, but LaTeX cannot directly read Word files, let alone Powerpoint or Excel. – darthbith Jan 19 '15 at 1:19
  • (Caveat lector: I know nothing about Windows servers, and virtually nothing about Windows.) If you can batch convert the files to PDF, then it would be fairly easy to do this with pdfpages. If you want to convert the .doc(x) files to .tex files on the fly, then probably not. I'd also export the Excel files to .csv and use something like datatool. I assume PowerPoint cannot be converted to a .tex file at all, however. – jon Jan 19 '15 at 1:20
  • You can export a .ppt to .pdf, though, and include the images - again with pdfpages. Why do you want to do this in LaTeX? – cfr Jan 19 '15 at 1:36
  • @jon I'm not sure it would be easy to add the footnotes, though. Would need to know a lot more about the set-up. (Are the footnotes the same for every page? Do all exported PDFs have sufficient room for them at the bottom of each page? Etc.) – cfr Jan 19 '15 at 1:39
  • @cfr -- Good point. I guess I assumed the 'footnotes' would be a footer, which would be much easier obviously. – jon Jan 19 '15 at 1:41
3

Since you say that you can covert all the different file types to PDF, then doing what you want isn't very difficult using the pdfpages package. As others have noted in the comments, there may be issues of margins in the source document not being sufficient for the footer, but I should think that these are solvable problems.

Here's a basic method to do this. I've made some simplifying assumptions about how your files are named, which allows the code to be inserted with a loop. If you need filenames to be more distinct from one another, you could use your python script to generate the whole latex document itself if needed. Alternatively you could store the filenames in a CSV file and use the datatool package to generate the document insertion loop.

Here's a simple example. It assumes that you have named each PDF file File1.pdf, File2.pdf,..., File*n*.pdf.

The document then adds a title page (with an image), and loops through inserting each file and adding a distinctive footer line with a rule and page number. I've made the document margins small to reduce the chances that the added footer will overlap with any existing footer in the documents.

\documentclass[12pt]{report}
\usepackage[margin=.75in,includefoot]{geometry}
\usepackage{pdfpages}
\usepackage{pgffor}
\usepackage{titleps}
\usepackage{titling}
\usepackage{graphicx}


\newpagestyle{main}{%
\setfootrule{3pt}
\setfoot{\itshape\sffamily My Footer Line}{}{\sffamily\itshape\thepage}}
\pagestyle{main}
\def\filecount{3} % change this to match the number of files
\title{My Bunch of Documents}
\author{My Name}
\date{}
% add image to titlepage using the titling package + graphicx
\postdate{\par\vfil\includegraphics{cow}\end{center}}
\begin{document}
\maketitle
\foreach \x in {1,...,\filecount}{
\includepdf[pages=1-,pagecommand={\thispagestyle{main}}]{File\x}
}
\end{document}

enter image description here enter image description here enter image description here enter image description here

| improve this answer | |
  • @Johannes_B our little argument brought this question to light! – Lynob May 9 '16 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.