Skip to content

Error when signing malformed docs (fix available) #248

@julienrffr

Description

@julienrffr

Document.Pages[Options.PageIndex].Elements.Add(PdfPage.Keys.Annots, new PdfArray(Document, signatureField));

Using .Add(...) throw an exception when the /Annots key exists.

I stumbled upon some PDF documents generated by www.princexml.com that has the /Annots key present in this dictionary, but the reference PDF object does not exist, in PdfSharp this gives a null value for the /Annots key in the dictionary.
For example the /Annots element references an object '70 0 R' but there is no element with this reference in the document.
Leading to .Add(...) throwing an exception.

Simple fix is to use the indexer of the dictionary to overwrite the value instead of throwing:
KDS@233b486

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions