Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdegeus/pdfcombine
Combine PDF files with Ghostscript
https://github.com/tdegeus/pdfcombine
Last synced: 11 days ago
JSON representation
Combine PDF files with Ghostscript
- Host: GitHub
- URL: https://github.com/tdegeus/pdfcombine
- Owner: tdegeus
- License: mit
- Created: 2019-11-08T17:42:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-05T07:56:13.000Z (about 1 year ago)
- Last Synced: 2024-09-16T11:28:13.662Z (about 2 months ago)
- Language: Python
- Size: 43.9 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pdfcombine
[![CI](https://github.com/tdegeus/pdfcombine/workflows/CI/badge.svg)](https://github.com/tdegeus/pdfcombine/actions)
[![Documentation Status](https://readthedocs.org/projects/pdfcombine/badge/?version=latest)](https://pdfcombine.readthedocs.io/en/latest/?badge=latest)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/pdfcombine.svg)](https://anaconda.org/conda-forge/pdfcombine)
[![PyPi release](https://img.shields.io/pypi/v/pdfcombine.svg)](https://pypi.org/project/pdfcombine/)Simple module to combine (concatenate) PDF-files using GhostScript:
## Command-line script
```none
pdfcombine [options] ...
```## Python module
```python
import pdfcombine
pdfcombine.combine(...)
```# Contents
- [Disclaimer](#disclaimer)
- [Getting pdfcombine](#getting-pdfcombine)
- [Using conda](#using-conda)
- [Using PyPi](#using-pypi)
- [From source](#from-source)
- [Usage](#usage)
- [Basic usage](#basic-usage)
- [Meta-data using PostScript](#meta-data-using-postscript)
- [Manipulate PostScript script from command-line](#manipulate-postscript-script-from-command-line)
- [Customise](#customise)
- [Manually specify](#manually-specify)
- [Suppress](#suppress)
- [Customise meta-data using YAML input file](#customise-meta-data-using-yaml-input-file)
- [Usage from Python](#usage-from-python)
- [Basic usage](#basic-usage-1)
- [Arguments](#arguments)
- [Options](#options)# Disclaimer
This library is free to use under the [MIT license](https://github.com/tdegeus/pdfcombine/blob/master/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](https://github.com/tdegeus/pdfcombine). As always, the code comes with no guarantee. None of the developers can be held responsible for possible mistakes.
Download: [.zip file](https://github.com/tdegeus/pdfcombine/zipball/master) | [.tar.gz file](https://github.com/tdegeus/pdfcombine/tarball/master).
(c - [MIT](https://github.com/tdegeus/pdfcombine/blob/master/LICENSE)) T.W.J. de Geus (Tom) | [email protected] | www.geus.me | [github.com/tdegeus/pdfcombine](https://github.com/tdegeus/pdfcombine)
# Getting pdfcombine
## Using conda
```bash
conda install -c conda-forge pdfcombine
```This will install all necessary dependencies.
## Using PyPi
```bash
pip install pdfcombine
```This will install the necessary Python modules, **but not GhostScript**.
## From source
```bash
# 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] ...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= Set the title of the output PDF.
--author= Set the author of the output PDF.
--no-bookmarks Do include bookmarks to the first page of each document.
--add-ps= Add commands to the generated PostScript script.
--ps= Overwrite the automatically generated PostScript script.
--no-ps Do not run any PostScript script (to edit meta-data).
-o, --output= 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](#yaml-input-file) and/or [customise](#customise-postscript-script) 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.:
```yaml
files:
- file: 1.pdf
title: First file
- file: 2.pdf
title: Second fileopenleft: 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:```yaml
files:
- 1.pdf
- 2.pdfopenleft: True
title: Binder
author: Tom de Geus
output: binder.pdf
```# Usage from Python
## Basic usage
```python
import pdfcombine
pdfcombine.combine(...)
```## Arguments
+ `files` (`` | `>`)
List of PDF files to combine.
+ `output` (``)
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` (``)
If specified the automatically generated PostScript script is overwritten with
the specified script.+ `add_ps` (``)
Append generated/specified PostScript script with the specified script.
+ `bookmarks` (**`True`** | `False` | `>`)
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` (``)
Specify PDF title. Defaults to "Binder".
+ `author` (``)
Specify PDF author. Defaults to "pdfcombine".
+ `verbose` (**`False`** | `True`)
Verbose all commands and their output.