You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Laurence Urbain (Jira)" <ji...@apache.org> on 2021/12/15 15:35:00 UTC

[jira] [Updated] (PDFBOX-5344) Adding a signature on nested fields has no effect

     [ https://issues.apache.org/jira/browse/PDFBOX-5344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Laurence Urbain updated PDFBOX-5344:
------------------------------------
    Description: 
Hi,

I am not able add a signature to a document if the signature field is nested (the signature field is not a direct child of the acro form).

When I call the method PDDocument.addSignature(), the signature field is properly marked as  "needs to be updated" but not its parents.

As a result, when the incremental save is done, the changes are lost.

To be able to add the signature for such field, all the parent fields in the hierachy should also be marked as "needs to be updated".

Please find a sample file attached.

Here is the code snippet to build it:
{code:java}
final PDDocument pdDocument = new PDDocument();
final PDPage page = new PDPage();
pdDocument.addPage(page);
PDAcroForm form = new PDAcroForm(pdDocument);
pdDocument.getDocumentCatalog().setAcroForm(form);

final PDNonTerminalField level1 = new PDNonTerminalField(form);
level1.setPartialName("level1");

form.getFields().add(level1);

final PDNonTerminalField level2 = new PDNonTerminalField(form);
level2.setPartialName("level2");

level1.setChildren(List.of(level2));

final PDSignatureField signatureField = new PDSignatureField(form);
signatureField.setPartialName("field1");
PDAnnotationWidget widget = signatureField.getWidgets().get(0);
widget.setRectangle(new PDRectangle(50, 700, 200, 20));
widget.setPage(page);
widget.setPrinted(true);
page.getAnnotations().add(widget);

level2.setChildren(List.of(signatureField)); {code}
Thanks

  was:
Hi,

I am not to sign a document if the signature field is nested (the signature field is not a direct child of the acro form).

When I call the method PDDocument.addSignature(), the signature field is properly marked as  "needs to be updated" but not its parents.

As a result, when the incremental save is done, the changes are lost.

To be able to add the signature for such field, all the parent fields in the hierachy should also be marked as "needs to be updated".

Please find a sample file attached.

Here is the code snippet to build it:
{code:java}
final PDDocument pdDocument = new PDDocument();
final PDPage page = new PDPage();
pdDocument.addPage(page);
PDAcroForm form = new PDAcroForm(pdDocument);
pdDocument.getDocumentCatalog().setAcroForm(form);

final PDNonTerminalField level1 = new PDNonTerminalField(form);
level1.setPartialName("level1");

form.getFields().add(level1);

final PDNonTerminalField level2 = new PDNonTerminalField(form);
level2.setPartialName("level2");

level1.setChildren(List.of(level2));

final PDSignatureField signatureField = new PDSignatureField(form);
signatureField.setPartialName("field1");
PDAnnotationWidget widget = signatureField.getWidgets().get(0);
widget.setRectangle(new PDRectangle(50, 700, 200, 20));
widget.setPage(page);
widget.setPrinted(true);
page.getAnnotations().add(widget);

level2.setChildren(List.of(signatureField)); {code}
Thanks


> Adding a signature on nested fields has no effect
> -------------------------------------------------
>
>                 Key: PDFBOX-5344
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5344
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Signing
>    Affects Versions: 2.0.24
>            Reporter: Laurence Urbain
>            Priority: Major
>         Attachments: nested-signature-field.pdf
>
>
> Hi,
> I am not able add a signature to a document if the signature field is nested (the signature field is not a direct child of the acro form).
> When I call the method PDDocument.addSignature(), the signature field is properly marked as  "needs to be updated" but not its parents.
> As a result, when the incremental save is done, the changes are lost.
> To be able to add the signature for such field, all the parent fields in the hierachy should also be marked as "needs to be updated".
> Please find a sample file attached.
> Here is the code snippet to build it:
> {code:java}
> final PDDocument pdDocument = new PDDocument();
> final PDPage page = new PDPage();
> pdDocument.addPage(page);
> PDAcroForm form = new PDAcroForm(pdDocument);
> pdDocument.getDocumentCatalog().setAcroForm(form);
> final PDNonTerminalField level1 = new PDNonTerminalField(form);
> level1.setPartialName("level1");
> form.getFields().add(level1);
> final PDNonTerminalField level2 = new PDNonTerminalField(form);
> level2.setPartialName("level2");
> level1.setChildren(List.of(level2));
> final PDSignatureField signatureField = new PDSignatureField(form);
> signatureField.setPartialName("field1");
> PDAnnotationWidget widget = signatureField.getWidgets().get(0);
> widget.setRectangle(new PDRectangle(50, 700, 200, 20));
> widget.setPage(page);
> widget.setPrinted(true);
> page.getAnnotations().add(widget);
> level2.setChildren(List.of(signatureField)); {code}
> Thanks



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org