Hi,
working with C# (.NET 2.0) and itextsharp (v 3.1.5) .
The piece of code at the end of thos mail is to sign a file.
When I sign a pdf and got the signed pdf into a file, it runs fine. (
as in the comment lines //xxx )
But if I want to keep the signed file in a MemoryStream in place of a
FileStream, when the signature has been done (st.close()), my
MemoryStream no longer exists, it has been "disposed" and I get a
System.ObjectDisposedException
Is there an error in the code? or st.close() makes free the stream
provided and I cannot use it?
Below the code:
PdfReader reader = new PdfReader("filetosign.pdf");
MemoryStream signedStream = new MemoryStream();
//xxx FileStream signedStream = new new FileStream("signedFile.pdf",
FileMode.Create, FileAccess.Write);
//In the next instruction I use a Memory Stream in place of a
FileStream to get the result
PdfStamper st = PdfStamper.CreateSignature(reader, signedStream, '\0',null);
st.SetEncryption(PdfWriter.STRENGTH128BITS, null,"hello",
PdfWriter.AllowPrinting);
PdfSignatureAppearance sap = st.SignatureAppearance;
sap.SetCrypto(this.myCert.Akp, this.myCert.Chain, null,
PdfSignatureAppearance.WINCER_SIGNED);
sap.Reason = "x";
sap.Contact = "y";
sap.Location = "z";
st.Close();
//xxx FileStream signedStream = new new FileStream("signedFile.pdf",
FileMode.Open, FileAccess.Read);
long numBytes = signedStream.Length; // HERE I GET THE EXCEPTION
Thanks for your help.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions