Hi Right... That works - thanks a lot!
Med venlig hilsen ________________________________________ Jan Eliasen WM-data Fredrik Bajers Vej 1 9220 Aalborg Øst Tel.: +45 9630 5800, direkte: +45 9630 5818 Mobil: +45 2518 8024, fax: +45 9630 5805 mailto: [EMAIL PROTECTED] http://www.wmdata.dk -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paulo Soares Sent: 14. juni 2006 15:43 To: Post all your questions about iText here Subject: Re: [iText-questions] Fill in Form and then sign Call SetEncryption() right after creating the PdfStamper. Paulo > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Eliasen Jan > Sent: Wednesday, June 14, 2006 1:01 PM > To: Post all your questions about iText here > Subject: [iText-questions] Fill in Form and then sign > > Hi > > I am trying to open up a PDF document, fill in some values into some > form fields and then sign the document at the end. > > Unfortunately, I can not get it to work. > > My code looks like this: > > string alias = null; > > string keyPath = > @"D:\Work\Projekter\DubliNet\Sikkerhed\Certifikatet\PrivateKey > WithCert.p12"; > > PKCS12Store pk12 = new PKCS12Store(new FileStream(keyPath, > FileMode.Open, FileAccess.Read), "TooHot4u".ToCharArray()); > > IEnumerator i = pk12.aliases(); > > while (i.MoveNext()) > > { > > alias = ((string)i.Current); > > if (pk12.isKeyEntry(alias)) > > break; > > } > > AsymmetricKeyParameter akp = pk12.getKey(alias).getKey(); > > X509CertificateEntry[] ce = pk12.getCertificateChain(alias); > > X509Certificate[] chain = new X509Certificate[ce.Length]; > > for (int k = 0; k < ce.Length; ++k) > > chain[k] = ce[k].getCertificate(); > > PdfReader reader = new PdfReader(new > FileStream(@"D:\Work\Projekter\DubliNet\Blanketter\20050104 > TakeBack filled out.pdf", FileMode.Open, FileAccess.Read)); > > string filename = > @"D:\Work\Projekter\DubliNet\Blanketter\20050104 TakeBack filled out > SIGNED.pdf"; > > System.IO.MemoryStream memStamp = new MemoryStream(); > > PdfStamper st = PdfStamper.CreateSignature(reader, new > FileStream(filename, FileMode.Create, FileAccess.Write), '\0'); > > AcroFields form = st.AcroFields; > > form.SetField("b_dd","15"); > > int perm = PdfWriter.AllowPrinting; > > st.SetEncryption(true, null, "lhkjshdfkjhsadfasdkljncaef", perm); > > PdfSignatureAppearance sap = st.SignatureAppearance; > > sap.SetCrypto(akp, chain, null, PdfSignatureAppearance.WINCER_SIGNED); > > sap.Reason = "I am approving this document"; > > sap.Location = "Danish immigration Service"; > > sap.SetVisibleSignature("signature"); > > st.Close(); > > > The exception occurs at the line where I create the > PdfSignatureAppearance - and the exception is this: > -- BEGIN > An unhandled exception of type > 'iTextSharp.text.DocumentException' occurred in itextsharp.dll > > Additional information: Content was already written to the output > -- END > > Thanks in advance! > > Med venlig hilsen > ________________________________________ > Jan Eliasen > > WM-data > Fredrik Bajers Vej 1 > 9220 Aalborg Øst > Tel.: +45 9630 5800, direkte: +45 9630 5818 > Mobil: +45 2518 8024, fax: +45 9630 5805 > mailto: [EMAIL PROTECTED] > http://www.wmdata.dk > > > Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
