Repository navigation
Hide page content in optional content groups that are turned off - #583
Merged
Merged
Conversation
Marked-content sequences tagged /OC were painted regardless of the document's layer settings, so content in a group listed under the default configuration's /OFF still rendered. Page content now honours optional content: - BDC keeps its property-list name, and Resources reads the optional content entries of /Properties. - The canvas gets an OptionalContentFilter that hides painting and text recording inside sequences whose group or membership is off. It only exists when the document turns some group off, so other documents pay nothing for marked content. - PdfRenderer and the web page renderer pass the visibility state, the web renderer sharing the annotation overlay's state. The optional content model moves out of pdf-annotation-core into a new pdf-optional-content crate, since rendering now depends on it. Its decoders are all FromPdfObject impls. A single /OCG reference is represented as a one-group /AnyOn membership, which collapses the former AnnotationOptionalContent enum into OptionalContentMembership. pdf-object-reader gains DictionaryContext::lenient_entries and optional_list for mixed namespaces and single-or-array entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conformance readsDocuments that Safe-PDF reads differently from the base commit, compared with PDFium. A read pdf.js corpus1008 documents compared with Regressions
840 documents of the PDFium corpus read as on Details are in the job summaries of the workflow run. Rerun a case locally with |
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
Content inside
/OCmarked-content sequences was painted no matter what the document's layer settings said. Content in a group listed under the default configuration's/OFFstill rendered, which differed from PDFium. Page content now respects optional content.BDCkeeps its property-list name.Resourcesreads the optional content entries of/Properties. A newOptionalContentFilterinpdf-canvasskips painting and text recording inside sequences whose group or membership is off. It is only created when the document turns some group off, so other documents pay nothing for marked content.PdfRendererpasses the document's default visibility. The web page renderer passes the annotation overlay's state, so page content and annotations share it.pdf-optional-contentcrate: the optional content model moves out ofpdf-annotation-corebecause rendering now depends on it. All its decoders areFromPdfObjectimpls. A single/OCGreference is stored as a one-group/AnyOnmembership, which merges the formerAnnotationOptionalContentenum intoOptionalContentMembership.DictionaryContext::lenient_entries(decode the entries that fit a type, skip the rest) andDictionaryContext::optional_list(one value or an array, nulls skipped).Notes
annotation_contract.tschanges:AnnotationOptionalContentis gone, and an annotation'soptional_contentis now anOptionalContentMembership./OCentry on a form or image XObject itself. On the web, page content picks up aSetOCGStatechange the next time the page is rendered.Testing
cargo check --workspace --all-targets,cargo clippy --all --workspaceandcargo fmt --checkare clean.cargo testwasn't run locally because the Skia build script downloads prebuilt binaries.cargo xtask annotation-types --checkpasses andcargo xtask web-canvas --profile debugbuilds.cargo conformance renderon TCPDF example 024 now matches PDFium: the line in the off layer is hidden, and the line in the on layer and the one in the other layer still show.🤖 Generated with Claude Code