First Steps

Installation

The easiest way to use pydyf is to install it in a Python virtual environment. When your virtual environment is activated, you can then install pydyf with pip:

pip install pydyf

Create a PDF

import pydyf

document = pydyf.PDF()

# Add an empty page
document.add_page(pydyf.Dictionary({
    'Type': '/Page',
    'Parent': document.pages.reference,
    'MediaBox': pydyf.Array([0, 0, 200, 200]),
}))

# Write to document.pdf
with open('document.pdf', 'wb') as f:
    document.write(f)