Welcome to Python PDF’s documentation!

Python PDF is a PDF library that aims to make creating PDF’s as simple as possible.

Installations

At the moment Python PDF is under development and doesn’t have a stable release, thus rather than installing from Pypi the best way to get started is by installing the HEAD from the git repository.

pip install -e git://github.com/d0ugal/paper.git#egg=paper

Or, go to http://github.com/d0ugal/paper and download a copy, extract and run python setup.py install

Usage

A simple usage example is shown below. By default, the the Python PDF document rendering system will create pages in a flowing style. This is similar to HTML and other formats where you don’t need to worry about page breaks and managing content.

Note

This example is not fully working, but rather the goal API for the development code. It’s getting close but the styling system is under work.

::

from paper import Document, Image, styles

paper = Document()

pdf(“Hello World”, styles=[styles.H1, ])

# Text by default is treated as paragraph text. pdf(“Python PDF is an effort to make writing PDF’s much cleaner, simpler and easier.”)

# Lists are by default show up as bullets, but we want a numbered list here. pdf([“Item 1”, “Item 2”, “Item 3”], styles=[styles.NUMBEREDLIST])

# Add an image on the right and have text wrap around it. pdf(Image(“/path/to/file”), styles=[styles.WRAP, styles.RIGHTALIGN])

pdf(“This text will wrap around the image.”)

paper.save(‘/output/path.paper’)

Feature Support

At present Python PDF supports a limited subset of the PDF specification with the aim of keeping a clean API and adding features gradually.

Basic image formatting and flowing text support is the biggest feature but it is still fairly limited as for example only JPEG images are supported.

The only fonts that are currently supported are Helvetica and Times Roman. This is one of the area’s that needs addressing first.

Project Versions

Table Of Contents

This Page