Skip to content

PoC: PdfCapabilities flags for selective content extraction - #1282

Open
EdwardBlair wants to merge 2 commits into
UglyToad:masterfrom
EdwardBlair:feature/parsing-capabilities
Open

PoC: PdfCapabilities flags for selective content extraction#1282
EdwardBlair wants to merge 2 commits into
UglyToad:masterfrom
EdwardBlair:feature/parsing-capabilities

Conversation

@EdwardBlair

Copy link
Copy Markdown

Proof of concept for the capabilities enum discussed in #980. Builds on top of #1281 (lazy stream loading).

Adds a PdfCapabilities flags enum to ParsingOptions so you can tell PdfPig what you actually need:

var options = new ParsingOptions
{
    Capabilities = PdfCapabilities.Text,
    LazyLoading = true
};

Flags are Text, Images, Paths, and All (the default, so nothing changes for existing users). Could add more (Colors, AcroForms, etc) if this direction makes sense.

With LazyLoading = false (the default), the capabilities flags skip processing of unwanted content which saves CPU but the raw stream bytes are still read into memory by the scanner. Combined with LazyLoading = true, skipped streams are never accessed so the bytes stay on disk - thats where the real memory savings come from.

TODO:

  • Thread ParsingOptions through to Page so we can throw if someone tries to access data they didn't extract (e.g. calling GetImages() when Images wasn't in capabilities)
  • More capability flags (Colors, AcroForms, etc)

Depends on #1281.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant