Discussion:
[iText-questions] Set visible signature on multiple/all pages
Carles Barrobés
2010-01-20 15:46:48 UTC
Permalink
Hi all,

I wonder whether it is possible to make one signature visible on more
than one location.
In my specific case I would like to make it visible on all pages.

But if I call the setVisibleSignature more than once for one
PdfSignatureAppearance, it ends up showing up only once at the last
location. E.g.:

PdfSignatureAppearance pdfSignatureAppearance;
// ...omitted initialisation code...

for (int page = 1; page <= lastPage; page++) {
pdfSignatureAppearance.setVisibleSignature(rectangle, page, null);
}

The visible signature appears on the last page only.

Is there a correct way to do this or is it a limitation of iText/PDF?
--
Carles Barrobés i Meix
*Isigma R&D*
http://www.isigma.es
mkl
2010-01-21 21:20:46 UTC
Permalink
Carles,
I wonder whether it is possible to make one signature visible on more than
one location.
Hhmmm, even though having a number of widget annotations (e.g. one per page)
for the same signature field can be constructed, I doubt that's supported,
especially after reading the section on signature fields in the
specification.
But if I call the setVisibleSignature more than once for one
PdfSignatureAppearance, it ends up showing up only once at the last
PdfSignatureAppearance pdfSignatureAppearance;
// ...omitted initialisation code...
for (int page = 1; page <= lastPage; page++) {
pdfSignatureAppearance.setVisibleSignature(rectangle, page, null);
}
The visible signature appears on the last page only.
This cannot do what you want. The method setVisibleSignature sets the
visible representation of a signature, it does not add another one. The last
call, therefore, sets the visible representation that eventually is used.

Regards, Michael.
--
View this message in context: http://old.nabble.com/Set-visible-signature-on-multiple-all-pages-tp27244918p27264771.html
Sent from the iText - General mailing list archive at Nabble.com.
mkl
2010-02-11 09:02:23 UTC
Permalink
Carles,

half a month ago you wondered
whether it is possible to make one signature visible on more than one
location.
which I doubted
Hhmmm, even though having a number of widget annotations (e.g. one per
page) for the same signature field can be constructed, I doubt that's
supported, especially after reading the section on signature fields in the
specification.
but that idea remained at the back of my mind.

Thus, I now simply tried it; and indeed, at least Acrobat and Reader v9.3
seem to accept such a construct!

E.g.
http://old.nabble.com/file/p27544126/2274_2007_H_PROVISIONAL%2B-%2Bmultifield%2B-%2BAdobe.pdf
MultiAnnotationSignature.pdf

Regards, Michael.
--
View this message in context: http://old.nabble.com/Set-visible-signature-on-multiple-all-pages-tp27244918p27544126.html
Sent from the iText - General mailing list archive at Nabble.com.
Elias_iText
2012-08-24 16:30:44 UTC
Permalink
Michael, can you give more details about this ? is there some code example
?
Tks.



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656019.html
Sent from the iText - General mailing list archive at Nabble.com.
mkl
2012-08-26 01:17:51 UTC
Permalink
Elias,
can you give more details about this ? is there some code example ?
If i recall correctly, I created a signature field with multiple widgets
with some one-shot code and signed that field using adobe acrobat. I don't
think I still have that code anywhere anymore.

If you actually want iText to create and verify such signatures, some
changes to its core classes (or some reflection magic) is required.

Please keep in mind, though, this note from Bruno's white paper: Is it
possible to have one signature correspond with more than one widget? I’m
sorry, but that’s not a good question. See the spec about digital signature
appearances by Adobe: “The location of a signature within a document can
have a bearing on its legal meaning. For this reason, signatures never refer
to more than one annotation. If more than one location is associated with a
signature the meaning may become ambiguous.

Thus, it may well happen that adobe software - when displaying a
multi-appearance signature - will eventually warn or even reject it.

Regards, Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656023.html
Sent from the iText - General mailing list archive at Nabble.com.
Elias_iText
2012-08-27 12:41:06 UTC
Permalink
Michael, good morning.

Really, I want to use the signature field properties to put a stamp on every
page, without causing any warning or notice in Acrobat Reader when you open
the document.

Today, when I put a annotation in a file previously signed, Acrobat Reader
reports that there was an update after the document was signed. I do not
want that happen.

So I'm looking for an alternative to placing a stamp on every page, telling
that I read the page and that this stamp or annotation does not cause alerts
in Acrobat Reader. After that, I put my signature on the final page.

On the Web, I found a small program that replicates a signature on all
pages. That program put a annotation on each page and put the same signature
reference for every annotation.

Look that:
16 0 obj
<</FT/Sig/T(Signature1)/V 9 0 R/F 132/Type/Annot/Subtype/Widget/Rect[50 50
150 100]/AP&lt;&lt;/N 15 0 R>>/P 4 0 R/DR<</XObject&lt;&lt;/FRM 14 0 R>>>>>>
endobj
7 0 obj
<</Type/Catalog/Pages 3 0 R/AcroForm&lt;&lt;/Fields[16 0 R 16 0 R]/DA(/Helv
0 Tf 0 g )/DR&lt;&lt;/XObject&lt;&lt;/FRM 14 0 R>>/Font<</Helv 17 0 R/ZaDb
18 0 R>>>>/SigFlags 3>>>>
endobj
6 0 obj
<</Parent 3 0 R/Contents 5 0
R/Type/Page/Resources&lt;&lt;/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Font&lt;&lt;/F1
1 0 R>>>>/MediaBox[0 0 595 842]/Annots[16 0 R]>>
endobj
4 0 obj
<</Parent 3 0 R/Contents 2 0
R/Type/Page/Resources&lt;&lt;/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Font&lt;&lt;/F1
1 0 R>>>>/MediaBox[0 0 595 842]/Annots[16 0 R]>>
endobj
3 0 obj
<</ITXT(5.0.6)/Type/Pages/Count 2/Kids[4 0 R 6 0 R]>>
endobj
8 0 obj
<</Producer(iText® 5.3.0 ©2000-2012 1T3XT BVBA; modified using iTextSharp
5.0.6 \(c\) 1T3XT
BVBA)/ModDate(D:20120824152750-03'00')/CreationDate(D:20120824152406-03'00')>>
endobj

Above, two pages with one annotation in each page. The annotations has the
same signature field reference. This works well. The Acrobatr not alert
anything, just informs that a signature is valid.

At last object described above(8 0 obj), I believe this has been done by
iText.


So I was wondering how to put the same reference of a signature for multiple
annotations as was done above or one best alternative to put my stamp on
each page in order that does not cause any alerts in Acrobat Reader.

If you can help me to how to do this using iText, I thank you.

Elias.






--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656033.html
Sent from the iText - General mailing list archive at Nabble.com.
Leonard Rosenthol
2012-08-27 12:59:15 UTC
Permalink
Elias - if you want to place a stamp after a signature, you first need to apply a Certifying signature to the PDF (prior to the first user signature) that states that annotations are allowed after signing. Otherwise, the stamps are not valid post-signing.

Of course, you could use actual signatures instead of simple stamps - and those would be fine, since you'd be creating new signatures. (and that's the case of the sample you displayed - they are real signatures) But this was done BEFORE (or well, as part of). Your problem is doing it AFTER signing.

Leonard

-----Original Message-----
From: Elias_iText [mailto:***@yahoo.com.br]
Sent: Monday, August 27, 2012 8:41 AM
To: itext-***@lists.sourceforge.net
Subject: Re: [iText-questions] Set visible signature on multiple/all pages

Michael, good morning.

Really, I want to use the signature field properties to put a stamp on every page, without causing any warning or notice in Acrobat Reader when you open the document.

Today, when I put a annotation in a file previously signed, Acrobat Reader reports that there was an update after the document was signed. I do not want that happen.

So I'm looking for an alternative to placing a stamp on every page, telling that I read the page and that this stamp or annotation does not cause alerts in Acrobat Reader. After that, I put my signature on the final page.

On the Web, I found a small program that replicates a signature on all pages. That program put a annotation on each page and put the same signature reference for every annotation.

Look that:
16 0 obj
<</FT/Sig/T(Signature1)/V 9 0 R/F 132/Type/Annot/Subtype/Widget/Rect[50 50
150 100]/AP&lt;&lt;/N 15 0 R>>/P 4 0 R/DR<</XObject&lt;&lt;/FRM 14 0 R>>>>>> endobj
7 0 obj
<</Type/Catalog/Pages 3 0 R/AcroForm&lt;&lt;/Fields[16 0 R 16 0 R]/DA(/Helv
0 Tf 0 g )/DR&lt;&lt;/XObject&lt;&lt;/FRM 14 0 R>>/Font<</Helv 17 0 R/ZaDb
18 0 R>>>>/SigFlags 3>>>>
endobj
6 0 obj
<</Parent 3 0 R/Contents 5 0
R/Type/Page/Resources&lt;&lt;/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Font&lt;&lt;/F1
1 0 R>>>>/MediaBox[0 0 595 842]/Annots[16 0 R]>> endobj
4 0 obj
<</Parent 3 0 R/Contents 2 0
R/Type/Page/Resources&lt;&lt;/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Font&lt;&lt;/F1
1 0 R>>>>/MediaBox[0 0 595 842]/Annots[16 0 R]>> endobj
3 0 obj
<</ITXT(5.0.6)/Type/Pages/Count 2/Kids[4 0 R 6 0 R]>> endobj
8 0 obj
<</Producer(iText® 5.3.0 ©2000-2012 1T3XT BVBA; modified using iTextSharp
5.0.6 \(c\) 1T3XT
BVBA)/ModDate(D:20120824152750-03'00')/CreationDate(D:20120824152406-03'00')>>
endobj

Above, two pages with one annotation in each page. The annotations has the
same signature field reference. This works well. The Acrobatr not alert
anything, just informs that a signature is valid.

At last object described above(8 0 obj), I believe this has been done by iText.


So I was wondering how to put the same reference of a signature for multiple annotations as was done above or one best alternative to put my stamp on each page in order that does not cause any alerts in Acrobat Reader.

If you can help me to how to do this using iText, I thank you.

Elias.
--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656033.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords
Elias_iText
2012-08-27 15:07:43 UTC
Permalink
I receive the signed PDF file and I have no control over the type of
signature.

Yes, the program does what I want, but I need this functionality to a bigger
system and in this case, the Web program does not work integrated. One
license is required and I would not buy a license just to figure out how it
makes, no sense.


Below part of my code:
...
PdfStamper stamper = PdfStamper.createSignature(reader, new
FileOutputStream(dest), '\0', null, true);
int qtypages = reader.getNumberOfPages();
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setReason("Test.");
appearance.setLocation("anywhere");
appearance.setVisibleSignature(new Rectangle(0,750, 30, 200), qtypages,
"mysignature");
appearance.setSignatureGraphic(image);
appearance.setRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
...


Here, I put the annotations on the pages :
...
for (int i = 1; i < qtypages; i++) {
PdfAnnotation stp = PdfAnnotation.createStamp(stamper.getWriter(), new
Rectangle(0,700,30, 200), "MY STAMP", "STP"+i);
PdfAppearance tp = PdfAppearance.createAppearance(stamper.getWriter(),
image.getPlainHeight(),image.getPlainWidth());
image.setAbsolutePosition(0, 0);
tp.addImage(image);
stp.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
stamper.addAnnotation(stp,i);
}
..

and I need to know how to put the signature field reference into the
annotation in order to that annotation show the signature content as does
the signature field.

Follow the site for the web program: http://www.signfiles.com/pdf-signer/


tks in advance.



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656036.html
Sent from the iText - General mailing list archive at Nabble.com.
Leonard Rosenthol
2012-08-27 15:37:17 UTC
Permalink
The PDF snippet that you sent was done PRE-SIGNING - that's the only way that it will work. You are trying to do it POST-SIGNING - that's not possible.

The ONLY WAY that you can get this to work will be if you put down your stamps first and then sign the PDF (again). In that case, your signature will make the stamps valid.

Leonard

-----Original Message-----
From: Elias_iText [mailto:***@yahoo.com.br]
Sent: Monday, August 27, 2012 11:08 AM
To: itext-***@lists.sourceforge.net
Subject: Re: [iText-questions] Set visible signature on multiple/all pages

I receive the signed PDF file and I have no control over the type of signature.

Yes, the program does what I want, but I need this functionality to a bigger system and in this case, the Web program does not work integrated. One license is required and I would not buy a license just to figure out how it makes, no sense.


Below part of my code:
...
PdfStamper stamper = PdfStamper.createSignature(reader, new FileOutputStream(dest), '\0', null, true); int qtypages = reader.getNumberOfPages(); PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); appearance.setReason("Test."); appearance.setLocation("anywhere");
appearance.setVisibleSignature(new Rectangle(0,750, 30, 200), qtypages, "mysignature"); appearance.setSignatureGraphic(image);
appearance.setRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
...


Here, I put the annotations on the pages :
...
for (int i = 1; i < qtypages; i++) {
PdfAnnotation stp = PdfAnnotation.createStamp(stamper.getWriter(), new Rectangle(0,700,30, 200), "MY STAMP", "STP"+i);
PdfAppearance tp = PdfAppearance.createAppearance(stamper.getWriter(),
image.getPlainHeight(),image.getPlainWidth());
image.setAbsolutePosition(0, 0);
tp.addImage(image);
stp.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
stamper.addAnnotation(stp,i);
}
..

and I need to know how to put the signature field reference into the annotation in order to that annotation show the signature content as does the signature field.

Follow the site for the web program: http://www.signfiles.com/pdf-signer/


tks in advance.



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656036.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
iText Info
2012-08-27 15:38:14 UTC
Permalink
Post by Elias_iText
I receive the signed PDF file and I have no control over the type of
signature.
If a PDF is signed, it could have restrictions.
You should assume that you can add annotations:
1.) without breaking the signature
2.) without causing a warning.
Post by Elias_iText
Yes, the program does what I want,
I don't think so, because what I've said above is inherent to the PDF
specification.
Post by Elias_iText
but I need this functionality to a bigger
system and in this case, the Web program does not work integrated. One
license is required and I would not buy a license just to figure out how it
makes, no sense.
Er... Two things:
1.) If the people at signfiles.com use iText(Sharp), they also need to
buy an iText license. (A mail has been sent to sales to check if they've
bought one.)
2.) If you plan on using iText, you'll probably need a license too,
won't you?
Post by Elias_iText
...
PdfStamper stamper = PdfStamper.createSignature(reader, new
FileOutputStream(dest), '\0', null, true);
int qtypages = reader.getNumberOfPages();
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setReason("Test.");
appearance.setLocation("anywhere");
appearance.setVisibleSignature(new Rectangle(0,750, 30, 200), qtypages,
"mysignature");
appearance.setSignatureGraphic(image);
appearance.setRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
...
But... but... you've just told us that you receive the signed PDF. Now
you're signing it once more. Is that your intention?
Post by Elias_iText
...
for (int i = 1; i < qtypages; i++) {
PdfAnnotation stp = PdfAnnotation.createStamp(stamper.getWriter(), new
Rectangle(0,700,30, 200), "MY STAMP", "STP"+i);
PdfAppearance tp = PdfAppearance.createAppearance(stamper.getWriter(),
image.getPlainHeight(),image.getPlainWidth());
image.setAbsolutePosition(0, 0);
tp.addImage(image);
stp.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
stamper.addAnnotation(stp,i);
}
..
and I need to know how to put the signature field reference into the
annotation in order to that annotation show the signature content as does
the signature field.
Strange... The annotation used for a signature is a Widget annotation,
yet you want it to be a Stamp annotation? The question is so confusing
that you probably won't get an answer.
Elias_iText
2012-08-27 16:39:15 UTC
Permalink
Post by iText Info
If a PDF is signed, it could have restrictions.
1.) without breaking the signature
2.) without causing a warning.
Yes, the first signature isn't broken, but there is some warning about the
my annotations.
Post by iText Info
1.) If the people at signfiles.com use iText(Sharp), they also need to
buy an iText license. (A mail has been sent to sales to check if they've
bought one.)
2.) If you plan on using iText, you'll probably need a license too,
won't you?
1 - I agree.
2 - I agree. But before, I need to make sure that works as I need.
Post by iText Info
But... but... you've just told us that you receive the signed PDF. Now
you're signing it once more. Is that your intention?
Yes, that's right. I'm the second signature, but I want to put my own
stamper on each page before sign.
Post by iText Info
Strange... The annotation used for a signature is a Widget annotation,
yet you want it to be a Stamp annotation? The question is so confusing
that you probably won't get an answer.
That code was my best try with annotations.
follow a code with widget:
...
PdfFormField sig = PdfFormField.createSignature(stamper.getWriter());
sig.setWidget(new Rectangle(0,750, 30, 200), null);
sig.setHighlighting(PdfAnnotation.HIGHLIGHT_NONE);
sig.setFlags(PdfAnnotation.FLAGS_READONLY | PdfAnnotation.FLAGS_PRINT);
sig.setFieldName("sig3");
sig.setPage(1);
stamper.addAnnotation(sig, 1);
...


With Widget, how can I set it to show or to have a behavior like the
signature field ? (the program's website makes it).
What I need to set in this code ? or if you have other code to me follow...


tks.





--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656042.html
Sent from the iText - General mailing list archive at Nabble.com.
1T3XT BVBA
2012-08-28 06:13:04 UTC
Permalink
Post by Elias_iText
Yes, the first signature isn't broken, but there is some warning about the
my annotations.
Whether or not a warning is shown depends entirely on the nature of the
first signature.
If it's a certification signature with MDP settings that allow adding
annotations, there won't be a yellow triangle.
If it's an approval signature, you'll have a yellow triangle before you
sign the document a second time, and a blue circle with an exclamation
point after signing the document a second time.

All of this is explained in the white paper section 2.5 entitled
"Signatures in PDF and workflow."

iText Info
2012-08-27 15:39:45 UTC
Permalink
Post by Elias_iText
One
license is required and I would not buy a license just to figure out how it
makes, no sense.
Sales confirms: the owners of the service you were using have bought an
iText license.
mkl
2012-08-27 15:53:42 UTC
Permalink
Elias,
Post by Elias_iText
I receive the signed PDF file and I have no control over the type of
signature.
If you get your hands on the PDF when it already is signed, it's too late!
Believe Leonard and Bruno!
So you do NOT receive a signed PDF but instead sign it yourself?!
Post by Elias_iText
and I need to know how to put the signature field reference into the
annotation in order to that annotation show the signature content as does
the signature field.
In that case take a look at PdfSignatureAppearance.preClose... here one
field with up to one visible widget is created and then the document is
serialized for hashing. This essentially is where you have to either patch
iText code directly or by use of reflection change its behavior. Or else you
have to duplicate lots of its code.
Post by Elias_iText
Follow the site for the web program: http://www.signfiles.com/pdf-signer/
As iText sales confirmed that they bought an iText license, you
unfortunately are not entitled to take a look at their code.

Regards, Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656040.html
Sent from the iText - General mailing list archive at Nabble.com.
mkl
2012-08-27 14:12:59 UTC
Permalink
Elias,
Post by Elias_iText
On the Web, I found a small program that replicates a signature on all
pages. That program put a annotation on each page and put the same
signature reference for every annotation.
[...]
Above, two pages with one annotation in each page. The annotations has
the same signature field reference. This works well. The Acrobatr not
alert anything, just informs that a signature is valid.
At last object described above(8 0 obj), I believe this has been done by
iText.
If I understand you correctly, that program you found already does what you
need. In that case simply consult its code. As it is iText 5.x based and you
reveived output from it, you most likely [unless the developer had bought a
license] are entitled to receive a copy of the sources.

If the program does not satisfy your needs, please explain in more detail
what the program does and what in contrast you actually want.

Regards, Michael

PS: Where, BTW, did you find that program?



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Set-visible-signature-on-multiple-all-pages-tp2172145p4656035.html
Sent from the iText - General mailing list archive at Nabble.com.
Loading...