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 pydyfVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to version 3.10 or later.
Refer to the pydyf documentation for alternative, non-deprecated methods for managing colors, shadings, text matrices, and transformations.
Remove the `version` and `identifier` arguments when initializing `pydyf.PDF()`. The constructor now expects only `self` as a positional argument.
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'`.
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`).
Install the library using pip: `pip install pydyf`. If using a virtual environment, ensure it is activated before installation and running your script.