Skip to main content

pdfcombine

CI Documentation Status Conda Version PyPi release

Simple module to combine (concatenate) PDF-files using GhostScript:

Command-line script

pdfcombine [options] <files>...

Python module

import pdfcombine
pdfcombine.combine(...)

Contents

Disclaimer

This library is free to use under the MIT license. Any additions are very much appreciated, in terms of suggested functionality, code, documentation, testimonials, word-of-mouth advertisement, etc. Bug reports or feature requests can be filed on GitHub. As always, the code comes with no guarantee. None of the developers can be held responsible for possible mistakes.

Download: .zip file | .tar.gz file.

(c - MIT) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/pdfcombine

Getting pdfcombine

Using conda

conda install -c conda-forge pdfcombine

This will install all necessary dependencies.

Using PyPi

pip install pdfcombine

This will install the necessary Python modules, but not GhostScript.

From source

# Download pdfcombine
git checkout https://github.com/tdegeus/pdfcombine.git
cd pdfcombine

# Install
python -m pip install .

This will install the necessary Python modules, but not GhostScript.

Usage

Basic usage

The usage is as follows (see pdfcombine --help):

Usage:
    pdfcombine [options] <files>...

Options:
    -y, --yaml              Read input files (and settings) from a YAML-file.
        --openleft          Enforce that each 'chapter' starts on an even page.
        --openright         Enforce that each 'chapter' starts on an odd page.
        --title=<arg>       Set the title of the output PDF.
        --author=<arg>      Set the author of the output PDF.
        --no-bookmarks      Do include bookmarks to the first page of each document.
        --add-ps=<arg>      Add commands to the generated PostScript script.
        --ps=<arg>          Overwrite the automatically generated PostScript script.
        --no-ps             Do not run any PostScript script (to edit meta-data).
    -o, --output=<arg>      Name of the output file. [default: binder.pdf]
    -f, --force             Force overwrite of existing output-file.
    -s, --silent            Do not print any progress.
        --verbose           Verbose all commands.
    -h, --help              Show help.
        --version           Show version.

Meta-data using PostScript

By default a PostScript script is used to set the meta-data of the output PDF-file. In particular, the output PDF gets a table of contents with bookmarks to the first page of each input 'document' and the input filename at title. To customise these titles and add meta-data use a YAML input file and/or customise the default PostScript script.

Manipulate PostScript script from command-line

Customise

--title

Set title of the output PDF.

--author

Set the author of the output PDF.

--no-bookmarks

Switch-off bookmarks added for each 'document'.

--add-ps

Add lines of PostScript code to the automatically generated script.

Manually specify

--ps

Set PostScript script (overwrites automatically generated script).

Suppress

--no-ps

Switch-off the use of a PostScript script.

Customise meta-data using YAML input file

To include custom bookmarks a YAML input file can be used, e.g.:

files:
    - file: 1.pdf
      title: First file
    - file: 2.pdf
      title: Second file

openleft: True
title: Binder
author: Tom de Geus
output: binder.pdf

Run pdfcombine as follows:

  pdfcombine -y input.yaml

All PDFs have the specified in the YAML file: no additional PDFs can be added from the command-line.

As observed the files field contains all input files (in the correct order) and the bookmark titles. In addition, any of the command-line options (long name without --) can be included. Note that specifying them will overwrite the corresponding command-line option. To use with automatic bookmarks (i.e. filenames), the above input file can be shortened to:

files:
    - 1.pdf
    - 2.pdf

openleft: True
title: Binder
author: Tom de Geus
output: binder.pdf

Usage from Python

Basic usage

import pdfcombine
pdfcombine.combine(...)

Arguments

  • files (<str> | <list<str>>)

    List of PDF files to combine.

  • output (<str>)

    Name of output file (overwritten if exists).

Options

  • openleft (False | True)

    Make sure each 'document' begins on a left-page.

  • openright (False | True)

    Make sure each 'document' begins on a right-page.

  • meta (True | False)

    Write meta-data using a PostScript script (see below for options: ps, add_ps, bookmarks, title, author).

  • ps (<str>)

    If specified the automatically generated PostScript script is overwritten with the specified script.

  • add_ps (<str>)

    Append generated/specified PostScript script with the specified script.

  • bookmarks (True | False | <list<str>>)

    If True the filenames are used as bookmarks in the automatically generated PostScript script. One can customise the bookmarks by specifying a list with one label per file.

  • title (<str>)

    Specify PDF title. Defaults to "Binder".

  • author (<str>)

    Specify PDF author. Defaults to "pdfcombine".

  • verbose (False | True)

    Verbose all commands and their output.

Metadata

Release files for pdfcombine 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdfcombine 1.1.5
File Size Uploaded
pdfcombine-1.1.5.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdfcombine 1.1.5
File Interpreter ABI Platform
pdfcombine-1.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / pdfcombine-1.1.5.tar.gz

Download URL pdfcombine-1.1.5.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dc0a994997708896d342a0de8081e1d580043c79311de2fa635d302b2420ef71
BLAKE2b-256 checksum
How to use checksums
63eeeb84fddf7ff00e837e6e13fbad23a4e915b059454963f6927390c2dbaab5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pdfcombine-1.1.5-py3-none-any.whl

Download URL pdfcombine-1.1.5-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aca45ec0e024159bb9c0fa45479c60b25964ea8dd32c353df151987a65268a3a
BLAKE2b-256 checksum
How to use checksums
23fbb571f8b1987632b372ed144155763932a0098c259d99330daaaee11ab592
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page