Expose annotation appearance streams and appearance state as public - #1359
Conversation
…roperties Annotation: Add NormalAppearance, RollOverAppearance, DownAppearance (AppearanceStream?) and AppearanceState (string?) public properties. HasNormal/RollOver/DownAppearance now delegate to these properties. No breaking changes. AppearanceStream.Get(state): For stateless streams, return the stream directly instead of throwing. This allows callers to use Get() uniformly without checking IsStateless first.
|
@jeske ill have a look shortly but do you mind having a look at https://github.com/BobLd/PdfPig.Rendering.Skia This is my own pdf rendered (it renders annotations too). Not saying this is the only way to do a rendered but the approach there expose everything you'd need Edit: it is using Skia, but you could use any another graphic engine |
Can you explain why you are suggesting this? Of course i can reparse annotations myself, as i said in my PR... "I can do it without this, but it means duplicating the parsing that is already there." PdfPig has Annotations parsing classes that as far as i can see are not used internally but also not exposed. what are they for if not to be exposed and used? I figured it would be good to expose and use them. If this patch isnt wanted, i can go the other route, but down this route it seems like PdfPig would delete annotations parsing that is not used and not exposed? Or did i miss something? Is there a way to get at the data of the internal annotations classes i missed? Humbly trying to help. |
|
@jeske no worries at all. Will check your changes shortly. I believe they are indeed needed |
|
@BobLd I see now what you meant... and the BaseStreamProcessor method... I'm going to refactor to use this now more like your Skia renderer. Thanks! |
|
@jeske if you see any changes in PdfPig that would simplify the logic for rendering, do not hesitate. Also, if you have any question about the skia rendered, do not hesitate to open a discussion there |
Updated [PdfPig](https://github.com/UglyToad/PdfPig) from 0.1.15 to 0.1.16. <details> <summary>Release notes</summary> _Sourced from [PdfPig's releases](https://github.com/UglyToad/PdfPig/releases)._ ## 0.1.16 ## What's Changed * Bump version to 0.1.16 by @github-actions[bot] in UglyToad/PdfPig#1344 * Better deal with infinite recursion in GlyphDataTable.ReadCompositeGlyph and fix #1347 by @BobLd in UglyToad/PdfPig#1348 * Accept out of range characterCode in type 3 font and fix #1349 by @BobLd in UglyToad/PdfPig#1350 * Correctly clamp values in IndexedColorSpaceDetails and fix #1351 by @BobLd in UglyToad/PdfPig#1352 * Ensure abbreviated key name takes precedence in inline images by @BobLd in UglyToad/PdfPig#1353 * Prevent infinite recursion when resolving default substitute color space and fix #1354 by @BobLd in UglyToad/PdfPig#1355 * Properly handle missing ColorSpace entry in JPX image and fix #1356 by @BobLd in UglyToad/PdfPig#1357 * Expose annotation appearance streams and appearance state as public by @jeske in UglyToad/PdfPig#1359 * PageBuilder: Fix importing page contents stored as indirect array by @MultisoftPontus in UglyToad/PdfPig#1358 * Properly override Equals and GetHashCode methods for IToken and add tests by @BobLd in UglyToad/PdfPig#1362 * Cache values in DeviceNColorSpaceDetails.GetColor() and improve Transform() method to use array by @BobLd in UglyToad/PdfPig#1363 * Cache color spaces in ResourceStore when possible by @BobLd in UglyToad/PdfPig#1364 * Make PdfFunctionType4.Eval() allocation-free and boxing-free by @BobLd in UglyToad/PdfPig#1365 * Fix: brute-force xref scan loses stream position, missing recoverable trailers by @jeske in UglyToad/PdfPig#1360 * Add integration test for 28a1878 (#1360) by @BobLd in UglyToad/PdfPig#1366 * Expose font dictionary indirect reference on FontDetails by @jeske in UglyToad/PdfPig#1367 * BUGFIX: Decode Indexed colour-table bytes to the base space's component ranges by @jeske in UglyToad/PdfPig#1369 * Do not clip form XObject when bbox is invalid and fix #1371 by @BobLd in UglyToad/PdfPig#1373 * Expose XmpMetadata.GetXmlMemory() and add warning to GetXDocument() by @BobLd in UglyToad/PdfPig#1374 * Move Indexed table-byte decoding onto the base colour space (in place) by @jeske in UglyToad/PdfPig#1375 * Fix wrong number of components for DeviceNColorSpaceDetails and SeparationColorSpaceDetails, and ensure BaseType is correctly set by @BobLd in UglyToad/PdfPig#1376 * Unseal ParsingOptions by @BobLd in UglyToad/PdfPig#1377 * Change GetColor() signature to use ReadOnlySpan<double> and avoid allocation by @BobLd in UglyToad/PdfPig#1378 * Split color space details in their own files by @BobLd in UglyToad/PdfPig#1379 * Prefer double array over span in IColorSpaceContext so that operands can be saved without allocation by @BobLd in UglyToad/PdfPig#1380 * Fix #1234 and ensure documents are disposed in Merge() by @BobLd in UglyToad/PdfPig#1382 * Use StackDictionary<> for marked content, shadings and patterns in ResourceStore by @BobLd in UglyToad/PdfPig#1384 * PdfPageBuilder: fix ResetColor() and line width in Draw methods by @BobLd in UglyToad/PdfPig#1385 * Expose ILookupFilterProvider in the doc's Structure, address IFilterProvider propagation and fix #1243 by @BobLd in UglyToad/PdfPig#1386 * Properly concatenate matrix in GetGlobalTransform and fix #1163 by @BobLd in UglyToad/PdfPig#1387 * Allow skipping token that are not an IndirectReferenceToken in BasePageFactory.Create and fix #1286 by @BobLd in UglyToad/PdfPig#1388 * Add PdfDocEncoding as a valid encoding in ReadEncodingDictionary when lenient is on and fix #1284 by @BobLd in UglyToad/PdfPig#1389 * Improve caching: found tokens in token scanner, resolved resources and XObject forms by @BobLd in UglyToad/PdfPig#1391 * Prevent NullReferenceException in NameToken.GetHashCode() race condition by @BobLd in UglyToad/PdfPig#1392 * Check unencrypted metadata in DecryptInternal() and fix #1393 by @BobLd in UglyToad/PdfPig#1395 * Track stack depth in CMapParser and fix #1394 by @BobLd in UglyToad/PdfPig#1396 * Include time in nightly version date format by @BobLd in UglyToad/PdfPig#1397 * Tidy up netstandard2.1 by @BobLd in UglyToad/PdfPig#1400 ## New Contributors * @MultisoftPontus made their first contribution in UglyToad/PdfPig#1358 **Full Changelog**: UglyToad/PdfPig@v0.1.15...v0.1.16 Commits viewable in [compare view](UglyToad/PdfPig@v0.1.15...v0.1.16). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
This is necessary for my PDF Renderer to access the Appearance Stream parsing inside PdfPig..
I can do it without this, but it means duplicating the parsing that is already there.
Here is a screenshot of PDF Highlight Annotations Rendering.