Registry / serialization / pydyf
library0.12.1pypypi✓ verified 27d ago

pydyf is a low-level PDF generator written in Python and based on PDF specification 1.7. It provides fine-grained control over PDF features such as bookmarks, attachments, links, color spaces, and text capabilities. The library is actively maintained with frequent releases, typically every 1-3 months.

pip install pydyf
INSTALL
IMPORT
SIG · PYDYF
P
pydyf
serializationpythonv0.12.1
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.12.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PDF
from pydyf import PDF
Stream
from pydyf import Stream
Dictionary
from pydyf import Dictionary
Array
from pydyf import Array

This example demonstrates how to create a basic PDF document, draw a red rectangle on a page, and save it to a file using pydyf.

import pydyf document = pydyf.PDF() draw = pydyf.Stream() # Set the drawing color to red draw.set_color_rgb(1.0, 0.0, 0.0) # Draw a rectangle draw.rectangle(10, 10, 100, 50) draw.fill() # Fill the rectangle # Add a page with the drawing stream document.add_page(pydyf.Dictionary({ 'Type': '/Page', 'MediaBox': pydyf.Array([0, 0, 200, 200]), 'Contents': draw, })) # Write the PDF to a file with open('output.pdf', 'wb') as f: document.write(f)
Debug
Known issues
breakingPython 3.8 and 3.9 are no longer supported. Users must upgrade to Python 3.10 or newer.
fix
Upgrade your Python environment to version 3.10 or later.
affects: >=0.12.0
breakingDeprecated methods `color_space`, `shading`, `text_matrix`, and `transform` have been removed from `pydyf.Stream`.
fix
Refer to the pydyf documentation for alternative, non-deprecated methods for managing colors, shadings, text matrices, and transformations.
affects: >=0.12.0
breakingThe deprecated `version` and `identifier` parameters were removed from `pydyf.PDF.__init__`. Calling `PDF()` with these arguments will now raise a `TypeError`.
fix
Remove the `version` and `identifier` arguments when initializing `pydyf.PDF()`. The constructor now expects only `self` as a positional argument.
affects: >=0.11.0
Errors
Common errors & fixes
TypeError: PDF.__init__() takes 1 positional argument but 3 were given
This error occurs because the `pydyf.PDF` constructor's signature changed in version 0.11.0, removing the `version` and `identifier` positional arguments.
fix
Instantiate `pydyf.PDF()` without any arguments. If you need to set the PDF version, assign it after creation, e.g., `pdf = pydyf.PDF(); pdf.version = '1.7'`.
AttributeError: 'super' object has no attribute 'transform'
This error arises due to breaking API changes in `pydyf` version 0.11.0 and later, where the `transform` method's inheritance or existence changed, affecting libraries that relied on the old API, such as `WeasyPrint` versions prior to 63.0.
fix
Ensure compatibility by either pinning `pydyf<0.11.0` (e.g., `pip install pydyf==0.10.0`) or upgrading downstream libraries (like `WeasyPrint`) to versions compatible with `pydyf>=0.11.0` (e.g., `WeasyPrint>=63.0`).
ModuleNotFoundError: No module named 'pydyf'
The Python interpreter cannot find the `pydyf` package, typically because it has not been installed, the virtual environment is not activated, or there is a misspelling in the import statement.
fix
Install the library using pip: `pip install pydyf`. If using a virtual environment, ensure it is activated before installation and running your script.
Upgrade
Version history
0.12.1latest on PyPI · released Dec 2, 2025
Audit
Dependencies
Pythonrequiredpydyf requires Python 3.10 or newer for the current version.
Agent activity
14 hits · last 30 days
node
12
Amazon
1
Resources