refactor: deduplicate PDF rendering by delegating to unstructured-inference#4315
Merged
refactor: deduplicate PDF rendering by delegating to unstructured-inference#4315
Conversation
Render and save each PDF page individually instead of accumulating all PIL images in a dict before saving. With path_only=True, peak memory drops from O(n_pages) to O(1 page).
973a994 to
ef1063e
Compare
…erence Delete _render_pdf_pages and delegate convert_pdf_to_image to unstructured-inference's implementation, which already has lazy per-page rendering. Bumps inference dep to >=1.6.2.
cragwolfe
pushed a commit
to Unstructured-IO/unstructured-inference
that referenced
this pull request
Apr 3, 2026
…structured (#501) ## Summary - Make `dpi` an explicit parameter (default 200) on `convert_pdf_to_image` instead of reading `inference_config.PDF_RENDER_DPI` internally - Enables unstructured to import and call this function directly, eliminating the duplicate `_render_pdf_pages` implementation - No behavior change — both internal callers already pass `dpi` explicitly ## Changelog ``` ## 1.6.2 ### Enhancement - Make `dpi` an explicit parameter on `convert_pdf_to_image` (default 200) instead of reading from config internally, enabling unstructured to use this as the single source of truth for PDF rendering ``` ## Depends on / blocks - Blocks Unstructured-IO/unstructured#4315 (dedup of PDF rendering) - Blocks Unstructured-IO/core-product#1480 (version bump)
- Add override-dependencies to relax inference's numpy/pandas floors (numpy>=2.4.2 → >=1.26.0, pandas>=3.0.0 → >=1.5.0) which conflict with kdbai-client via pykx - Add Python version marker so 3.11 falls back to inference >=1.2.0 (1.6.x requires Python >=3.12)
0.22.13 is already taken on main by the standardize_quotes change.
cragwolfe
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_render_pdf_pagesfrompdf_image_utils.py(~70 lines)convert_pdf_to_imageandconvert_pdf_to_imagestounstructured-inference's implementation (which already has lazy per-page rendering since v1.5.5)env_config.PDF_RENDER_DPIexplicitly instead of relying on internal configunstructured-inferencedep to>=1.6.2Peak memory for
path_only=Truedrops from O(n_pages) to O(1 page) — 97% reduction on a 100-page PDF.Depends on
dpiexplicit)