Datagrunt 4.5.0: High-Fidelity PDF Page Rendering and Security Hardening
We are thrilled to announce the release of Datagrunt 4.5.0. This release focuses on extending our PDF processing toolkit, laying down robust security foundations for our automated supply chain, and introducing a self-publishing document pipeline.
High-Fidelity PDF Page Rasterization
While Datagrunt has long supported extracting embedded images via PDFWriter.extract_images(), we frequently received requests for whole-page rendering (rasterization).
Why Rasterization Matters
Extracting embedded images pulls individual assets (like charts, logos, and signatures) from the document, but it ignores background formatting, styles, and text-only pages. In contrast, rasterization compiles every element of a page—text, shapes, backgrounds, and images—into a single, high-fidelity visual snapshot.
Datagrunt 4.5.0 introduces a robust, native method to accomplish this: PDFWriter.render_pages_as_images():
from datagrunt import PDFWriter
# Initialize the writer (PDFium engine is used by default)
writer = PDFWriter("quarterly_report.pdf")
# Render each page to 300 DPI PNG images inside a specific directory
img_paths = writer.render_pages_as_images(
output_dir="rendered_pages",
dpi=300,
image_format="png"
)
# img_paths contains: ["rendered_pages/quarterly_report_page_1.png", ...]Core Rendering Mechanics
- Custom Formats and Resolutions: The
image_formatargument accepts"png","jpg", or"jpeg"(case-insensitive). The output resolution is fully tunable via thedpi(dots per inch) parameter. - Dual Engine Support: The feature works transparently on both the default PDFium (BSD-licensed) and PyMuPDF (AGPL-licensed) engines.
- Process-Level Concurrency: When using the default PDFium engine, rasterization respects the process count specified in the constructor. Multi-core machines can render pages in parallel using isolated workers:
if __name__ == '__main__': # Spin up 4 workers to render pages concurrently on PDFium writer = PDFWriter("large_manual.pdf", workers=4) writer.render_pages_as_images("output_dir", dpi=150) - Fault Isolation: Pages are processed inside defensive try-except blocks. If a corrupt page fails to render, Datagrunt logs a page-level warning, skips the single page, and continues parsing the remaining pages. The returned list consists of every successfully written path, returned in correct page order.
- Short-Circuit and Fail-Fast Safety: Invalid values for
image_formatinstantly raise aValueErrorduring validation before any file checks start, complying with our fail-fast API design.
Behind the Scenes: The Self-Referential Release Pipeline
This release marks a milestone in how Datagrunt is maintained. With feat(ci): add automatic docs & blog publisher, we have officially integrated Google Gemini (gemini-3.5-flash) via the google-antigravity package directly into our CI/CD workflows.
Whenever our version numbers are bumped in pyproject.toml, our GitHub action (auto-publish-site.yml) automatically spawns an intellectual release agent. This agent:
- Analyzes the commit logs, file statistics, and code diffs between releases.
- Updates the Hugo site documentation with precision.
- Drafts the Markdown blog post you are currently reading!
This process drastically reduces release friction and guarantees that every feature addition receives up-to-date documentation on day one.
Try It Out
We recommend using uv for efficient dependency management in your Python projects. Update to version 4.5.0 today:
uv pip install --upgrade "datagrunt[pdf]"Enjoy the release, and happy data engineering!