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
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 0.4 | Imported from PyPI (0.4) | Low | 4/21/2026 |
| v0.4 | 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 | Low | 9/18/2017 |
| v0.3 | Several fixes and new examples, including: - Logging was improved (PR #44) - PageMerge bug with multiple program runs was fixed (issue #50, PR #56 ) - PageMerge with state save/restore was fixed (issue #36) - In-memory PDF support was improved (issues #38 and #59, PR #43) - from pdfrw import * now works properly (issue #35) - Added Python 3.5 to regression testing - fancy_watermark.py example works with watermarks and pages of differing sizes, and shows usage of the PageMerge class | Low | 4/2/2017 |
| v0.2 | Several new features, including Python 3 support, as described in the README. | Low | 6/21/2015 |
| v0.1.0 | Release v0.1.0 | Low | 6/1/2015 |
