Hi,

I could not find where to post bug reports so I'll send email.  I am  
pretty sure I found (and fixed) a bug in iTextsharp:

         using (MemoryStream memStream = new MemoryStream())
         {
             PdfStamper stamper = PdfStamper.CreateSignature(reader,  
memStream, '\0');
             stamper.Writer.CloseStream = false;
             try
             {
                 PdfSignatureAppearance sap =  
stamper.SignatureAppearance;

                 sap.SetCrypto(akp, chain, null,  
PdfSignatureAppearance.SELF_SIGNED);
                 // FIXME Change to VERISIGN when time is right
                 sap.Reason = signReason;
                 sap.Location = signLocation;
                 sap.SetVisibleSignature(new Rectangle(100, 100, 200,  
200), 1, null);
             }
             finally
             {
                 stamper.Close();
             }

             byte[] signedPDF = new byte[memStream.Length];
             memStream.Seek(0, SeekOrigin.Begin);
             Utility.readFile(memStream, signedPDF);

             return signedPDF;
         }

That code excepts with an ObjectDisposedException on the line "byte[]  
signedPDF = new byte[memStream.Length];".  that is why I added  
"stamper.Writer.CloseStream = false;" which is supposed to cause  
"stamper.Close();" NOT to close the outputstream.  It seems it does  
not honor this flag.  I have changed this code to make it work:

In: PdfSignatureAppearance.cs

Method: public void Close(PdfDictionary update)

Changed the last lines from

                 if (originalout != null)
                     try{originalout.Close();}catch{}

to

                 if (originalout != null)
                     try{if (stamper.Writer.CloseStream)   
originalout.Close();}catch{}

Regards,
Waldo



_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to