# pdfrw

> PDF file reader/writer library

- **URL**: https://www.freshcrate.ai/projects/pdfrw
- **Author**: Patrick Maupin
- **Category**: Security
- **Latest version**: `0.4` (2026-04-21)
- **License**: MIT
- **Source**: https://github.com/pmaupin/pdfrw
- **Language**: Python
- **GitHub**: 1,911 stars, 277 forks
- **Registry**: pypi (`pdfrw`)
- **Tags**: `graphics`, `join`, `nup`, `pdf`, `pypi`, `split`, `vector`, `watermark`

## Description

==================
pdfrw 0.4
==================

:Author: Patrick Maupin

.. contents::
    :backlinks: none

.. sectnum::

Introduction
============

**pdfrw** is a Python library and utility that reads and writes PDF files:

* Version 0.4 is tested and works on Python 2.6, 2.7, 3.3, 3.4, 3.5, and 3.6
* Operations include subsetting, merging, rotating, modifying metadata, etc.
* The fastest pure Python PDF parser available
* Has been used for years by a printer in pre-press production
* Can be used with rst2pdf to faithfully reproduce vector images
* Can be used either standalone, or in conjunction with `reportlab`__
  to reuse existing PDFs in new ones
* Permissively licensed

__ http://www.reportlab.org/


pdfrw will faithfully reproduce vector formats without
rasterization, so the rst2pdf package has used pdfrw
for PDF and SVG images by default since March 2010.

pdfrw can also be used in conjunction with reportlab, in order
to re-use portions of existing PDFs in new PDFs created with
reportlab.


Examples
=========

The library comes with several examples that show operation both with
and without reportlab.


All examples
------------------

The examples directory has a few scripts which use the library.
Note that if these examples do not work with your PDF, you should
try to use pdftk to uncompress and/or unencrypt them first.

* `4up.py`__ will shrink pages down and place 4 of them on
  each output page.
* `alter.py`__ shows an example of modifying metadata, without
  altering the structure of the PDF.
* `booklet.py`__ shows an example of creating a 2-up output
  suitable for printing and folding (e.g on tabloid size paper).
* `cat.py`__ shows an example of concatenating multiple PDFs together.
* `extract.py`__ will extract images and Form XObjects (embedded pages)
  from existing PDFs to make them easier to use and refer to from
  new PDFs (e.g. with reportlab or rst2pdf).
* `poster.py`__ increases the size of a PDF so it can be printed
  as a poster.
* `print_two.py`__ Allows creation of 8.5 X 5.5" booklets by slicing
  8.5 X 11" paper apart after printing.
* `rotate.py`__ Rotates all or selected pages in a PDF.
* `subset.py`__ Creates a new PDF with only a subset of pages from the
  original.
* `unspread.py`__ Takes a 2-up PDF, and splits out pages.
* `watermark.py`__ Adds a watermark PDF image over or under all the pages
  of a PDF.
* `rl1/4up.py`__ Another 4up example, using reportlab canvas for output.
* `rl1/booklet.py`__ Another booklet example, using reportlab canvas for
  output.
* `rl1/subset.py`__ Another subsetting example, using reportlab canvas for
  output.
* `rl1/platypus_pdf_template.py`__ Another watermarking example, using
  reportlab canvas and generated output for the document.  Contributed
  by user asannes.
* `rl2`__ Experimental code for parsing graphics.  Needs work.
* `subset_booklets.py`__ shows an example of creating a full printable pdf
  version in a more professional and pratical way ( take a look at
  http://www.wikihow.com/Bind-a-Book )

__ https://github.com/pmaupin/pdfrw/tree/master/examples/4up.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/alter.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/booklet.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/cat.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/extract.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/poster.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/print_two.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rotate.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/subset.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/unspread.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/watermark.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rl1/4up.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rl1/booklet.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rl1/subset.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rl1/platypus_pdf_template.py
__ https://github.com/pmaupin/pdfrw/tree/master/examples/rl2/
__ https://github.com/pmaupin/pdfrw/tree/master/examples/subset_booklets.py

Notes on selected examples
------------------------------------

Reorganizing pages and placing them two-up
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A printer with a fancy printer and/or a full-up copy of Acrobat can
easily turn your small PDF into a little booklet (for example, print 4
letter-sized pages on a single 11" x 17").

But that assumes several things, including that the personnel know how
to operate the hardware and software. `booklet.py`__ lets you turn your PDF
into a preformatted booklet, to give them fewer chances to mess it up.

__ https://github.com/pmaupin/pdfrw/tree/master/examples/booklet.py

Adding or modifying metadata
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The `cat.py`__ example will accept multiple input files on the command
line, concaten

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `0.4` | 2026-04-21 | Low | Imported from PyPI (0.4) |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |
| `v0.4` | 2017-09-18 | Low | Fixes, enhancements, and new examples:    * Python 3.6 added to test matrix   * Proper unicode support for text strings in PDFs added   * buildxobj fixes allow better support creating form XObjects     out of compressed pages in some cases   * Compression fixes for Python 3+   * New subset_booklets.py example   * Bug with non-compressed indices into compressed object streams fixed   * Bug with distinguishing compressed object stream first objects fixed   * Better error reporting added |

## Citation

- HTML: https://www.freshcrate.ai/projects/pdfrw
- Markdown: https://www.freshcrate.ai/projects/pdfrw.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/pdfrw/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
