feat: add use_cropbox parameter to align rasterizer APIs
Added use_cropbox parameter to rasterize_pdf_page hook to allow choosing between MediaBox and CropBox rendering: - Default is use_cropbox=False (MediaBox) for consistency with Ghostscript's existing behavior - Ghostscript: passes -dUseCropBox when use_cropbox=True - pypdfium: calculates crop values to expand from CropBox to MediaBox when use_cropbox=False This aligns both rasterizers to produce the same output dimensions by default, making the rasterizer choice transparent for page geometry. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
ae783b4ae6
commit
3e46b039ed
@@ -214,6 +214,7 @@ def rasterize_pdf_page(
|
||||
filter_vector: bool,
|
||||
stop_on_soft_error: bool,
|
||||
options: OCROptions | None,
|
||||
use_cropbox: bool,
|
||||
) -> Path: # type: ignore[return-value]
|
||||
"""Rasterize one page of a PDF at resolution raster_dpi in canvas units.
|
||||
|
||||
@@ -240,6 +241,9 @@ def rasterize_pdf_page(
|
||||
options: OCRmyPDF options. Plugins may use this to check settings like
|
||||
``options.rasterizer`` to determine whether they should handle the
|
||||
request or defer to another plugin. Introduced in version 17.0.
|
||||
use_cropbox: If True, rasterize the page's CropBox instead of the
|
||||
MediaBox. Default is False (use MediaBox) for consistency with
|
||||
Ghostscript's default behavior.
|
||||
|
||||
Returns:
|
||||
Path: output_file if successful
|
||||
|
||||
Reference in New Issue
Block a user