ajrcarey / pdfium-render

A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
https://crates.io/crates/pdfium-render
Other
367 stars 60 forks source link

Transforming a page object does not regenerate content streams #168

Open ajrcarey opened 1 month ago

ajrcarey commented 1 month ago

Regeneration of content streams is tracked by the page and page object collection objects, not by the individual objects themselves. This means it's possible to mutate a page object (e.g. by applying a transform) and have the containing page object collection (and therefore the containing page) be unaware of the mutation, and therefore not regenerate the page content streams.

It should be possible to use the page index cache to our advantage. Adding an additional flag there to indicate that a page is "dirty" and needs to have its content streams regenerated would allow objects to directly inform a page of the need to regenerate.

ajrcarey commented 3 weeks ago

Expanded PdfPageIndexCache to store property structs instead of raw PdfPageIndex values, and implemented in-place mutation of previously cached properties.