Package: pdf-config
A simple, easy-to-script tool for merging multiple PDF files into one
document using a YAML configuration file.The program is written in Python, using thePyPDF4library.PurposeThere are many good utilities for splitting and merging PDF files. For
instance, if you prefer one with a GUI,PDF
Arrangeris a good
choice. However, I had slightly different requirements: * Composing
several documents from a similar set of files, but each time with slight
modifications. * Creating a structure of bookmarks, so that it is
easier to navigate the larger document. * Original PDF features such as
hyperlinks and the page orientation should remain intact.FeaturesSimple YAML configuration file structureAdding PDF metadataCreating bookmarks, also with nested structuresChecking the version of merged PDF files and setting the minimum in
the output PDFInstallationPrerequisitesThis program requires Python 3.6+.WindowsDownload and install fromhttps://www.python.org/downloads/.MacOS XThe best is to useHomebrewand install usingbrewinstallpythonLinuxInstall Python using your distribution’s package manager. Usually the
package is namedpython3.Virtual environmentIt is not strictly required but strongly advised to create avirtual
environmentfor installing Python packages for a specific purpose.Create one in any preferred location usingvirtualenv-ppython3pdfconfigThe last argument can also be changed if preferred. Then activate the
new environment:sourcepdfconfig/bin/activateInstalling this toolpipinstallpdf-configUsageConfiguration fileA configuration file is set up inYAML
syntaxwith the following
components:metadata:# Optionaltitle:My document titleauthor:ME# Additionally supported:# creator, keywords, producer, subject# Hard-coded version to set in the header. Set to 'auto' or leave out# entirely for using the maximum version of all input documents.version:'1.6'paths:# Optional# List of paths to look up any files that do not contain a path# specification. The current directory is checked first, then the following# directories are checked in that order.-~/my-pdfs# User home directory can be referred to.-$ADDITIONAL_PDF_PATH# Environment variables are also supported.contents:# The only required element# Each list entry can contain any of the following:# bookmark: The bookmark title# document: The name (and path) of the input file.# contents: An additional list of contents. Any bookmarks in this sub-structure#   are placed under this bookmark, if present.-bookmark:Firstdocument:first.pdf-bookmark:Secondcontents:-bookmark:Second doc 1document:sd1.pdf-bookmark:Second doc 2document:sd2.pdf-bookmark:Thirddocument:~/pdfpath/third.pdf# Relative and absolute paths are supported.contents:-bookmark:Third doc 1document:$PDF_T1# Environment variables are also expanded.-bookmark:Third doc 2document:$PDF_T2The order ofmetadata,paths, andcontentsabove is not
relevant. The resulting PDF bookmark structure will be|-First
|
|-Second
| |-Second doc 1
| |-Second doc 2
|
|-Third
  |-Third doc 1
  |-Third doc 2Secondpoints to the same page asSecond doc 1, whereasThirdandThird doc 1point to different pages, sinceThirdinserts pages on its own.StartWith the configuration stored insample.yamland the PDF files in
place, start the merging process by runningpdfconfigsample.yamlThis will merge the listed PDF files intosample.pdf. For changing
the output name, simply append it to the end of the line; e.g. runpdfconfigsample.yamlpath/to/output.pdfIn Windows, usepdfconfig.exe.For more explanation, runpdfconfig----help