[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


How to merge PDF-files

Introduction

PDF (Portable Document Format) is a file format invented by Adobe. PDF is useful to present documents independent of hardware, operating system and application software. Each PDF file has a fixed layout, including page size, fonts, graphics and other information. It is also possible to encrypt a PDF file for security, or create a digital signature for authentication.

Work in Progress!!!

PDF documents are created from traditional text-documents via a printer-driver, or as with LaTeX created directly from a source-code. One important consequence is, that one cannot convert a PDF-document “back” into it's original, for example a MS-Word document.

This article describes, how one can merge several PDF-documents into one. This is useful for example if you have several pages from the scanner in PDF-format and want to put this files to be in one file like the original text. There are several tools, some included in the stock Slackware install, some available via slackbuilds.org.

The Tools

At first I will describe the tools which are already available on your Slackware computer if you have a complete installation.

gs (GhostScript)

With GhostScript you can merge PDF files on the commandline

gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=<newfilename>.pdf <inputfilenameshere>

Thanks to mrclisdue from linuxquestions.org for the contribution.

ImageMagick (convert)

FIXME People say that it is also possible to merge PDF documents with convert, but I haven't yet found out how this works.

pdftk

pdftk is available at slackbuilds.org. It's also a commandline tool and the usage is:

pdftk first.pdf second.pdf third.pdf cat output altogether.pdf

pdftk can do more things than joining PDF files, for example rotating a document by 180 degrees is done this way:

pdftk upsidedown.pdf cat 1-endsouth output rotated.pdf

pdfshuffler

pdfshuffler is also available at slackbuilds.org. It comes with a graphical user interface and is written in Python, therefore pyPdf and pypoppler are required in order to get this program to work. It is very convenient because it shows the pages which are joined. I has additional features like rotating or splitting PDF files.

pdfjam

pdfjam is a LaTeX-package which is unfortunately not included in tetex. But those of us who have instead texlive installed have already pdfjam. It is also a commandline tool (like LaTeX). The documentation is available with the texdoc command

texdoc pdfjam
TODO: handling bookmarks in PDF-files, which of the above tools can handle those bookmarks?

Sources

 howtos:software:how_to_merge_pdf-files ()