Add lazy stream loading to reduce memory for large PDFs#1281
Open
EdwardBlair wants to merge 1 commit intoUglyToad:masterfrom
Open
Add lazy stream loading to reduce memory for large PDFs#1281EdwardBlair wants to merge 1 commit intoUglyToad:masterfrom
EdwardBlair wants to merge 1 commit intoUglyToad:masterfrom
Conversation
This was referenced Apr 16, 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.
Adds
ParsingOptions.LazyLoading(off by default) which defers reading stream bytes until they're actually needed. With this on,page.GetImages()gives you width, height, bounding box etc without loading the image data into memory - the bytes only get read if you actually access them.For the file path overload this means using a FileStream instead of File.ReadAllBytes so the data stays on disk. Should help with #1171 where big images cause OOM on cheap nodes.
This could also work as a foundation for #980 - the lazy stream infrastructure means a future capabilities enum could skip processing images/paths entirely and the byte data would never leave disk.