Skip to content

Print the visual representation of a digital signature - #387

Open
AlexanderV wants to merge 1 commit into
empira:masterfrom
AlexanderV:upstream/print-flag
Open

Print the visual representation of a digital signature#387
AlexanderV wants to merge 1 commit into
empira:masterfrom
AlexanderV:upstream/print-flag

Conversation

@AlexanderV

Copy link
Copy Markdown

The widget annotation of a signature field gets no /F entry, so its annotation flags are 0.

ISO 32000, 12.5.3 Annotation flags, on the print flag (bit position 3):

If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of whether it is displayed on screen.

So the visual representation of a signature created by PDFsharp is visible on screen, but it is missing on paper and in every export that goes through printing.

Other producers set the flag. In archives/samples-1.5/PDFs/fw4.pdf of the PDFsharp assets — an Adobe generated IRS form — all 45 annotations carry /F 4.

The change

/F is set to PdfAnnotationFlags.Print when the signature field is created. Hidden and NoView stay clear, so nothing else about the visibility changes. Four lines in DigitalSignatureHandler.GetSignatureField.

Test

Pdf.Signatures/SignatureAppearanceTests.cs signs a document, reads it back and checks the flags of the signature field: Print set, Hidden and NoView clear.

The test uses a dummy IDigitalSigner, so it needs no certificate, no assets and no network, and it runs in milliseconds.

Verified on top of current master: full PdfSharp.Tests suite green (253 passed, 0 failed).

This PR is independent of my other PRs; each of them applies to master on its own.

The widget annotation of a signature field got no /F entry, so its annotation
flags are 0. According to 12.5.3 Annotation flags, the print flag must be set
for an annotation to be printed: "If clear, never print the annotation, even if
it is displayed on screen." The visual representation of a signature was
therefore visible on screen, but missing on paper and in every export that
prints the pages.

Other producers set the flag, e.g. every annotation of the Adobe generated
IRS form fw4.pdf has /F 4.

The flag is now set when the signature field is created. Hidden and NoView stay
clear, so nothing else about the visibility changes.

The test needs no certificate, no assets and no network, because it uses a
dummy signer.
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.

2 participants