[
https://issues.apache.org/jira/browse/PDFBOX-4433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16763517#comment-16763517
]
Osman commented on PDFBOX-4433:
-------------------------------
[~tilman],
First of all, thanks that you lead me to the right path, yes, that was I was
looking for.
I tried several things, but they did not work and I think I need your help. And
also I checked that in pdfbox does not even use FieldMDP. When I really add
these dictionaries properly, will it calculate the hash properly?
I will share my code, can you please tell me is it okay?
Regards
Here is my code:
{code:java}
PDSignatureField signatureField = getSignatureField(pdDocument, pdSignature);
if (signatureField != null) {
COSDictionary lockDict = new COSDictionary();
lockDict.setItem(COSName.TYPE, COS_NAME_SIG_FIELD_LOCK);
lockDict.setItem(COS_NAME_ACTION, COS_NAME_EXCLUDE);
COSArray lockFields = new COSArray();
lockFields.add(new COSString("textbox1"));
lockDict.setItem(COS_NAME_FIELDS, lockFields);
signatureField.getCOSObject().setItem(COS_NAME_LOCK, lockDict);
COSDictionary transformParams = new COSDictionary(lockDict);
transformParams.setItem(COSName.TYPE,
COSName.getPDFName("TransformParams"));
transformParams.setItem(COSName.V, COSName.getPDFName("1.2"));
transformParams.setDirect(true);
COSDictionary sigRef = new COSDictionary();
sigRef.setItem(COSName.TYPE, COSName.getPDFName("SigRef"));
sigRef.setItem(COSName.getPDFName("TransformParams"), transformParams);
sigRef.setItem(COSName.getPDFName("TransformMethod"),
COSName.getPDFName("FieldMDP"));
//sigRef.setItem(COSName.getPDFName("Data"),
pdDocument.getDocumentCatalog());
sigRef.setDirect(true);
COSArray referenceArray = new COSArray();
referenceArray.add(sigRef);
pdSignature.getCOSObject().setItem(COSName.getPDFName("Reference"),
referenceArray);
}
{code}
> PDF Form updating while signing
> -------------------------------
>
> Key: PDFBOX-4433
> URL: https://issues.apache.org/jira/browse/PDFBOX-4433
> Project: PDFBox
> Issue Type: Task
> Components: Signing
> Reporter: Osman
> Priority: Major
> Labels: how-to
>
> Hi All,
> Actually I wanted to ask a question, I could not find the appropriate place
> to ask. If there is a more appropriate place, please forward me.
> My question is that I want to sign documents in a sequence but between
> signings, I want to change some fields which have their own signatures. It is
> supported by PDF and until now I always used PDFBox but I could not achieve
> it.
> Whenever I sign a document and change a field and sign again, previous
> signature becomes invalid.
> How can I solve this problem?
> Regards
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]