Concatenating Together PDFs for Academic Papers

Photo by Nicholas Kinar.

When writing academic papers, I often find that journals want a single PDF file for initial submission.  This PDF file includes the document, graphics and tables. 

I use Microsoft Word to write papers since the software supports Zotero and is WYSIWYG.  The Word files can also be easily shared with another author who also uses Windows and Word.

If I was writing just for myself, I would probably use LaTeX for the programmable features and Lyx for the frontend, but I digress.

I tend to initially structure the paper using multiple files:

  1. Main Document
  2.  Figures
  3. Tables
  4. Anything else (i.e. Appendices)

If I make a change to a file, I then have to export each file as a PDF and concatenate them together.  This is tedious to do by hand. 

Over time, I've developed a script-based workflow.  The sh script posted below uses a Python library and command-line utility docx2pdf to manually convert all Word documents in a directory.  Then, I use the mpdf utility that I wrote myself to merge the PDF files together.  The example below assumes that the mpdf utility has been added to the path.

#!/bin/sh
rm ./*.pdf
docx2pdf ./ &&
mpdf 1.pdf 2.pdf 3.pdf 4.pdf out.pdf

The shebang is at the top of the file, the rm command removes all PDF files currently in the directory (for good measure), the docx2pdf utility converts all of the Word documents to PDFs, and the mpdf utility concatenates the files.

If the mpdf utility is not on your path, then you can add the Python script to the folder and using Python3, run:

python3 mpdf.py 1.pdf 2.pdf 3.pdf 4.pdf out.pdf

On Windows, the python3 executable might be named python for 32-bit installs of the Python language.  Install the 64-bit version of Python on Windows and the executable will be named python3.  On Mac OS X and versions of GNU/Linux, the python executable is usually named python3.

The shell script can be run using the excellent cmdir console emulator for Windows.

 

This article was updated on August 28, 2020

Dr. Nicholas J. Kinar

Dr. Nicholas J. Kinar is a hydrologist and researcher at the University of Saskatchewan. This is a blog of ideas, techniques and things that Nicholas perceives as unsophisticated knowledge in the Homeland of the Métis / Treaty 6 Territory / Saskatoon, Saskatchewan, Canada / Earth. His full name is Nicholas John Stanislaus Kinar. This blog of unsophisticated knowledge is intended to document some information that Nicholas finds useful. However, he does not mind if other people might find this information to be useful as well.