You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Suma Rani <su...@gmail.com> on 2015/05/26 12:54:00 UTC

Fillin forms after signing

Hello,

I am trying to change a form after signing. The flow is like this:
1. add a form to the existing document
2. Fill some of the fields and sign it
3. Change the above fields/ fill some other fields and sign it again.

1 and 2 are done. no problem with that. But the signature becomes invalid
when I do the 3rd. Both signatures are invisible and my first signature
allows form fill-in. NO problem when i edit it with adobe reader. This is
the code I am using for the part  3.

PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setReason("Signing second time");
signature.setSignDate(Calendar.getInstance());

PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
PDField field = acroForm.getField("field2");
COSString fieldValue = new COSString("FIELD2");
field.getDictionary().setItem(COSName.V, fieldValue);
doc.addSignature(signature, this);
doc.saveIncremental(fis, fos);// Of course, doc.save() wont work.
doc.close();

In short, I would like to know how to add form fill-ins by saveincremental

Thanks

Re: Fillin forms after signing

Posted by Suma Rani <su...@gmail.com>.
Hey Thomas,

I will look into adapting addSignature. Thanks.

On Wed, May 27, 2015 at 11:37 AM, Thomas Chojecki <in...@rayman2200.de>
wrote:

> Hi Suma,
> the saveIncremantal is for signing purpose only. It is current a
> limitation of the writer that only work recursively. If you want to save
> the document with the filled forms, you need to give the writer a hint like
> breadcrumbs, so he knows that you alter the page and filled the forms.
>
> Otherwise, you need to fill them before signing and saving it regular with
> the save(...) method.
>
> You can take a look at the PDDocument/COSDocument addSignature method to
> know how it works at the moment for signing and adapt it to your purpose.
>
> Maybe in a coming 2.x version of the pdfbox, this will be solved.
>
> Best regards
> Thomas
>
> Zitat von Suma Rani <su...@gmail.com>:
>
>
>  Sorry. When i do saveIncremental, the signature is valid but the form
>> field
>> value is not changed. If I do save, the fiedvalue is correct, but the
>> signatures fail.
>>
>> On Tue, May 26, 2015 at 6:09 PM, Maruan Sahyoun <sa...@fileaffairs.de>
>> wrote:
>>
>>  Hi,
>>>
>>> > Am 26.05.2015 um 12:54 schrieb Suma Rani <su...@gmail.com>:
>>> >
>>> > Hello,
>>> >
>>> > I am trying to change a form after signing. The flow is like this:
>>> > 1. add a form to the existing document
>>> > 2. Fill some of the fields and sign it
>>> > 3. Change the above fields/ fill some other fields and sign it again.
>>> >
>>> > 1 and 2 are done. no problem with that. But the signature becomes
>>> invalid
>>> > when I do the 3rd.
>>>
>>> what do you mean by invalid. Is it that you get a warning sign in Adobe
>>> Reader or Acrobat? Or is it that the signature is corrupt ….
>>>
>>> BR
>>> Maruan
>>>
>>> > Both signatures are invisible and my first signature
>>> > allows form fill-in. NO problem when i edit it with adobe reader. This
>>> is
>>> > the code I am using for the part  3.
>>> >
>>> > PDSignature signature = new PDSignature();
>>> > signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
>>> > signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
>>> > signature.setReason("Signing second time");
>>> > signature.setSignDate(Calendar.getInstance());
>>> >
>>> > PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
>>> > PDField field = acroForm.getField("field2");
>>> > COSString fieldValue = new COSString("FIELD2");
>>> > field.getDictionary().setItem(COSName.V, fieldValue);
>>> > doc.addSignature(signature, this);
>>> > doc.saveIncremental(fis, fos);// Of course, doc.save() wont work.
>>> > doc.close();
>>> >
>>> > In short, I would like to know how to add form fill-ins by
>>> saveincremental
>>> >
>>> > Thanks
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Fillin forms after signing

Posted by Thomas Chojecki <in...@rayman2200.de>.
Hi Suma,
the saveIncremantal is for signing purpose only. It is current a  
limitation of the writer that only work recursively. If you want to  
save the document with the filled forms, you need to give the writer a  
hint like breadcrumbs, so he knows that you alter the page and filled  
the forms.

Otherwise, you need to fill them before signing and saving it regular  
with the save(...) method.

You can take a look at the PDDocument/COSDocument addSignature method  
to know how it works at the moment for signing and adapt it to your  
purpose.

Maybe in a coming 2.x version of the pdfbox, this will be solved.

Best regards
Thomas

Zitat von Suma Rani <su...@gmail.com>:

> Sorry. When i do saveIncremental, the signature is valid but the form field
> value is not changed. If I do save, the fiedvalue is correct, but the
> signatures fail.
>
> On Tue, May 26, 2015 at 6:09 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
>
>> Hi,
>>
>> > Am 26.05.2015 um 12:54 schrieb Suma Rani <su...@gmail.com>:
>> >
>> > Hello,
>> >
>> > I am trying to change a form after signing. The flow is like this:
>> > 1. add a form to the existing document
>> > 2. Fill some of the fields and sign it
>> > 3. Change the above fields/ fill some other fields and sign it again.
>> >
>> > 1 and 2 are done. no problem with that. But the signature becomes invalid
>> > when I do the 3rd.
>>
>> what do you mean by invalid. Is it that you get a warning sign in Adobe
>> Reader or Acrobat? Or is it that the signature is corrupt ….
>>
>> BR
>> Maruan
>>
>> > Both signatures are invisible and my first signature
>> > allows form fill-in. NO problem when i edit it with adobe reader. This is
>> > the code I am using for the part  3.
>> >
>> > PDSignature signature = new PDSignature();
>> > signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
>> > signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
>> > signature.setReason("Signing second time");
>> > signature.setSignDate(Calendar.getInstance());
>> >
>> > PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
>> > PDField field = acroForm.getField("field2");
>> > COSString fieldValue = new COSString("FIELD2");
>> > field.getDictionary().setItem(COSName.V, fieldValue);
>> > doc.addSignature(signature, this);
>> > doc.saveIncremental(fis, fos);// Of course, doc.save() wont work.
>> > doc.close();
>> >
>> > In short, I would like to know how to add form fill-ins by
>> saveincremental
>> >
>> > Thanks
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>




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


Re: Fillin forms after signing

Posted by Suma Rani <su...@gmail.com>.
Sorry. When i do saveIncremental, the signature is valid but the form field
value is not changed. If I do save, the fiedvalue is correct, but the
signatures fail.

On Tue, May 26, 2015 at 6:09 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> Hi,
>
> > Am 26.05.2015 um 12:54 schrieb Suma Rani <su...@gmail.com>:
> >
> > Hello,
> >
> > I am trying to change a form after signing. The flow is like this:
> > 1. add a form to the existing document
> > 2. Fill some of the fields and sign it
> > 3. Change the above fields/ fill some other fields and sign it again.
> >
> > 1 and 2 are done. no problem with that. But the signature becomes invalid
> > when I do the 3rd.
>
> what do you mean by invalid. Is it that you get a warning sign in Adobe
> Reader or Acrobat? Or is it that the signature is corrupt ….
>
> BR
> Maruan
>
> > Both signatures are invisible and my first signature
> > allows form fill-in. NO problem when i edit it with adobe reader. This is
> > the code I am using for the part  3.
> >
> > PDSignature signature = new PDSignature();
> > signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
> > signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
> > signature.setReason("Signing second time");
> > signature.setSignDate(Calendar.getInstance());
> >
> > PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
> > PDField field = acroForm.getField("field2");
> > COSString fieldValue = new COSString("FIELD2");
> > field.getDictionary().setItem(COSName.V, fieldValue);
> > doc.addSignature(signature, this);
> > doc.saveIncremental(fis, fos);// Of course, doc.save() wont work.
> > doc.close();
> >
> > In short, I would like to know how to add form fill-ins by
> saveincremental
> >
> > Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Fillin forms after signing

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 26.05.2015 um 12:54 schrieb Suma Rani <su...@gmail.com>:
> 
> Hello,
> 
> I am trying to change a form after signing. The flow is like this:
> 1. add a form to the existing document
> 2. Fill some of the fields and sign it
> 3. Change the above fields/ fill some other fields and sign it again.
> 
> 1 and 2 are done. no problem with that. But the signature becomes invalid
> when I do the 3rd.

what do you mean by invalid. Is it that you get a warning sign in Adobe Reader or Acrobat? Or is it that the signature is corrupt ….

BR
Maruan

> Both signatures are invisible and my first signature
> allows form fill-in. NO problem when i edit it with adobe reader. This is
> the code I am using for the part  3.
> 
> PDSignature signature = new PDSignature();
> signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
> signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
> signature.setReason("Signing second time");
> signature.setSignDate(Calendar.getInstance());
> 
> PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
> PDField field = acroForm.getField("field2");
> COSString fieldValue = new COSString("FIELD2");
> field.getDictionary().setItem(COSName.V, fieldValue);
> doc.addSignature(signature, this);
> doc.saveIncremental(fis, fos);// Of course, doc.save() wont work.
> doc.close();
> 
> In short, I would like to know how to add form fill-ins by saveincremental
> 
> Thanks


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