PdfSmartCopy cause signature corrupt
Eric Chow <[email protected]> Wed, 14 Oct 2015 12:53:21 +0800
| Newsgroups | gmane.comp.java.lib.itext.general |
|---|---|
| Message-ID | <CAO5vti-5xH3_muf-RzUwA4m-qu6YjjuyxSjS355Cre_ysoYFNg@mail.gmail.com> |
--===============4368997868687137601==
Content-Type: multipart/alternative; boundary=001a114e761e84847e05220957ad
--001a114e761e84847e05220957ad
Content-Type: text/plain; charset=UTF-8
Hello,
I use PdfSmartCopy to merge two PDF files.
One of the PDF file contains a Digital Signature.
After I used PdfSmartCopy to merge them, there is not any signature filed
in the side bar of Adobe reader.
If I click on the signature field in the pdf page, it shows the signature
data is corrupted.
Is there anything I miss to do? Please help!
The following is my code to merge two files:
OutputStream os = new FileOutputStream(out);
Document document = new Document();
PdfSmartCopy copy = new PdfSmartCopy(document, os);
document.open();
String[] files = { "pdf_has_signature.pdf", "another_pdf.pdf" };
PdfReader reader;
int n;
for (int i = 0; i < files.length; i++) {
reader = new PdfReader(files[i]);
// loop over the pages in that document
n = reader.getNumberOfPages();
for (int page = 1; page <= n; page++) {
copy.addPage(copy.getImportedPage(reader, page));
}
cop
copy.freeReader(reader);
reader.close();
}
--001a114e761e84847e05220957ad
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello,<div><br></div><div>I use PdfSmartCopy to merge two =
PDF files.<br></div><div><br></div><div>One of the PDF file contains a Digi=
tal Signature.=C2=A0</div><div>After I used PdfSmartCopy to merge them, the=
re is not any signature filed in the side bar of Adobe reader.<br></div><di=
v><br></div><div>If I click on the signature field in the pdf page, it show=
s the signature data is corrupted.</div><div><br></div><div>Is there anythi=
ng I miss to do? Please help!</div><div><br></div><div><br></div><div>The f=
ollowing is my code to merge two files:</div><div><br></div><div><br></div>=
<div><br></div><div><div>OutputStream os =3D new FileOutputStream(out);</di=
v><div><span class=3D"" style=3D"white-space:pre"> </span></div><div><span=
class=3D"" style=3D"white-space:pre"> </span></div><div>Document document=
=3D new Document();</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0</div><div>PdfSma=
rtCopy copy =3D new PdfSmartCopy(document, os);</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0</div><div>document.open();</div><div>=C2=A0 =C2=A0=
=C2=A0 =C2=A0=C2=A0</div><div>=C2=A0String[] files =3D { "pdf_has_sig=
nature.pdf", "another_pdf.pdf" };</div><div>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0=C2=A0</div><div><br></div><div>PdfReader reader;</div><div>in=
t n;</div><div><br></div><div>for (int i =3D 0; i < files.length; i++) {=
</div><div>=C2=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 reader =3D new PdfReader(files[i]);</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 // loop over the pages in that document</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n =3D reader.getNumberOfPages();</di=
v><div><br></div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div>=
<div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (int page =3D 1; page &l=
t;=3D n; page++) {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 copy.addPage(copy.getImportedPage(reader, page));</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }</div><div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 cop</div><div><br></div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 copy.freeReader(reader);</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 reader.close();</div></div><div><br></div><div>}</=
div></div></div>
--001a114e761e84847e05220957ad--
--===============4368997868687137601==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
--===============4368997868687137601==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
iText-questions mailing list
[email protected]
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
--===============4368997868687137601==--