Thank you so much for your feedback.
Hope to hear news about the solution tomorrow, and if it is not going to be
fixed in C# yet, please, let me know so that I can change my downloaded
source code meanwhile.
Regards,
Jose.
El martes, 28 de agosto de 2012, Paulo Soares escribió:
> It's a bug both in Java and C#. It only happens with PDFs with
> compressed object streams. It will be fixed tomorrow.
>
> Paulo
>
> On Tue, Aug 28, 2012 at 5:16 PM, José Santiago Bonilla Pazmiño
> <[email protected]> wrote:
> > Sure, attached an example from the external tool that generates the PDFs.
> >
> > When signing the original "reader" everything is OK, but when signing the
> > duplicate "readerCopy", Adobe Reader X shows error:
> > "There was a problem reading this document (14)"
> >
> > I tried with some PDF files from the same source, and the same behaviour.
> >
> > And, this is the code, with iTextSharp 5.3.2:
> >
> > String CERT_PATH = "../signingCert.p12";
> > String CERT_PASSW = "Password";
> >
> > string IN_FILE = "manual_desobediencia.pdf";
> > string OUT_FILE = "manual_desobediencia_signed.pdf";
> >
> > FileStream fs = new FileStream(CERT_PATH, FileMode.Open);
> > Pkcs12Store ks = new Pkcs12Store(fs, CERT_PASSW.ToCharArray());
> > string alias = null;
> > foreach (string al in ks.Aliases)
> > {
> > if (ks.IsKeyEntry(al) && ks.GetKey(al).Key.IsPrivate)
> > {
> > alias = al;
> > break;
> > }
> > }
> > fs.Close();
> > ICipherParameters pk = ks.GetKey(alias).Key;
> > X509CertificateEntry[] x = ks.GetCertificateChain(alias);
> > X509Certificate[] chain = new X509Certificate[x.Length];
> > for (int k = 0; k < x.Length; ++k)
> > {
> > chain[k] = x[k].Certificate;
> > }
> >
> > PdfReader reader = new PdfReader(IN_FILE);
> > PdfReader readerCopy = new PdfReader(reader);
> >
> > FileStream fout = new FileStream(OUT_FILE, FileMode.Create);
> > PdfStamper stp = PdfStamper.CreateSignature(readerCopy, fout, '\0', null,
> > true);
> > PdfSignatureAppearance sap = stp.SignatureAppearance;
> > sap.SetVisibleSignature(new iTextSharp.text.Rectangle(100, 100, 300,
> 200),
> > 1, "Signature");
> >
> > IExternalSignature es = new PrivateKeySignature(pk, "SHA-256");
> >
> > MakeSignature.SignDetached(sap, es, chain, null, null, null, 0,
> > CryptoStandard.CADES);
> >
> > El martes, 28 de agosto de 2012, Paulo Soares escribió:
> >
> >> Works for me in C#. Can you post the PDF you use?
> >>
> >> Paulo
> >>
> >> On Tue, Aug 28, 2012 at 2:52 PM, José Santiago Bonilla Pazmiño
> >> <[email protected]> wrote:
> >> > Thanks Michael,
> >> >
> >> > I think there is some diference between Java and C#. I tried this code
> >> > without running anything else than the copy and the signature of that
> >> > copy,
> >> > and Error 14 in Adobe Reader again.
> >> >
> >> > I will keep trying, hope to find a solution.
> >> >
> >> > Regards,
> >> >
> >> > Jose.
> >> >
> >> > El martes, 28 de agosto de 2012, mkl escribió:
> >> >
> >> >> José,
> >> >>
> >> >> José Santiago Bonilla Pazmiño wrote
> >> >> > PdfReader pdfCopy = new PdfReader(pdf); //I need to keep the
> original
> >> >> > PdfReader for a background process, reading again the file takes 20
> >> >> > secs
> >> >> > per each.
> >> >> >
> >> >> > After that, I tried to sign the pdfCopy:
> >> >>
> >> >> I just tested this using iText TRUNK for Java: I created one original
> >> >> PdfReader. Then I twice created a copy using the copy constructor and
> >> >> signed
> >> >> that copy. There is no problem with the resulting signatures.
> >> >>
> >> >> Maybe the problem is your "background process". If that background
> >> >> process
> >> >> runs in a separate thread, you probably create a copy when the
> original
> >> >> is
> >> >> in some dirty state. In that case the background process should use a
> >> >> separate PdfReader copy and the original PdfReader should only be
> used
> >> >> to
> >> >> take copies from.
> >> >>
> >> >> Maybe, on the other hand, there is some difference between the Java
> and
> >> >> the
> >> >> C# version.
> >> >>
> >> >> Regards, Michael
--
Saludos cordiales,
José Bonilla
(+593) 95031497
------------------------------------------------------------------------------
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
[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