Problem using PdfFileSignature with MemoryStream

Last post 02-03-2012, 3:22 PM by codewarior. 4 replies.
Sort Posts: Previous Next
  •  02-24-2010, 9:44 PM 223939

    Problem using PdfFileSignature with MemoryStream

    Hi

    I am evaluating the PDF kit for a document generation workflow.  I have managed to use memory streams as the input and output stream in all the Aspose words and PDF Kit classes I have used so far.

    Unfortunately, when I try and save to a memory stream with the PdfFileSignature class, I get exception "Empty path name is not legal".

    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at x2871a49da29933f7.xa4d177a239676c65..ctor(String file)
       at x2871a49da29933f7.xc95d892347c4a4d2..ctor(String file, String password)
       at Aspose.Pdf.Kit.Signature.Stamp(Stream stream)
       at xeb116a323308e2f7.x34d3ddaf504aefea.xd1e589c3e6c349cd(Stream xcf18e5243f8d5fd3, Signature x2f9ad81484440792)
       at xeb116a323308e2f7.x3233d061fc77cddd.close()
       at Aspose.Pdf.Kit.PdfFileSignature.Save(Stream outputStream)

    My looks like this
    public void Execute(Stream inStream, Stream outStream)
    {  
        Certificate cert = new Certificate(myCertMemoryStream, "mypwd");
        PdfFileSignature pdfSign = new PdfFileSignature(cert);
        pdfSign.SignatureAppearance = Path.Combine(signatureFilePath);
        pdfSign.CertificationLevel = PdfFileSignature.CertifiedNoChangeAllowed;
        pdfSign.BindPdf(inStream);
        System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
        pdfSign.Sign(2, "Fred", "success", "ChangSha", true, rect);
        pdfSign.Save(outStream);
    }

    where inStream and outStream are both memory streams.

    Any ideas?  I really don't want to use files if I can help it.

    Thanks

     
  •  02-25-2010, 6:25 AM 224038 in reply to 223939

    Re: Problem using PdfFileSignature with MemoryStream

    Hi Yamaan,

    Thank you very much for considering Aspose.

    I have reproduced this issue at my end and logged it as PDFKITNET-14679 in our issue tracking system. Our team will look into this issue and you'll be updated via this forum thread once the issue is resolved.

    We're sorry for the inconvenience.
    Regards,





    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  09-08-2010, 12:55 AM 257489 in reply to 223939

    Re: Problem using PdfFileSignature with MemoryStream

    The issues you have found earlier (filed as 14679) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
  •  02-02-2012, 1:33 PM 359037 in reply to 257489

    Re: Problem using PdfFileSignature with MemoryStream .NET

    I am having the same error on the current version (6.0)

    {"Path cannot be null.\r\nParameter name: path"}

    Here is the code:

    certStream.Seek(0, SeekOrigin.Begin);

    //PdfFileSignature pdfSign = new PdfFileSignature(fNameIn, fNameOut);

    PdfFileSignature pdfSign = new PdfFileSignature();

    ms.Seek(0, SeekOrigin.Begin);

    pdfSign.BindPdf(ms);

    ms.Dispose();

    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(480, 523, 300, 35);

    pdfSign.CertificationLevel = PdfFileSignature.CertifiedNoChangeAllowed;

    Pkcs1Signature signature = new Pkcs1Signature(certStream, encPwd); // PKCS#1 or

    signature.Reason = coSignerInfo;

    signature.Name = Context.User.Identity.Name;

    signature.Location = "";

    signature.Contact = Context.User.Identity.Name;

    pdfSign.Sign(string.Format("CoSign{0}", (i + 1).ToString()), signature);

    ms = new MemoryStream();

    pdfSign.Save((MemoryStream)ms);

    Here is the stack trace:

       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at xeb116a323308e2f7.x34d3ddaf504aefea.xd1e589c3e6c349cd(String x4a21632d4ad5636b, Signature x2f9ad81484440792)
       at xeb116a323308e2f7.x3233d061fc77cddd.close(String inputFile, Signature sig)
       at Aspose.Pdf.Kit.PdfFileSignature.xd68275b7e3d98460(Stream xf823f0edaa261f3b, x7759a935a2782a02 x618aa16cc0d53b64)
       at Aspose.Pdf.Kit.PdfFileSignature.Save(Stream outputStream)
       at coSignLog(Byte[] cert, Byte[] maLog) in C:\Visual Studio MACoSignLog.aspx.cs:line 751
       at SolutionsCubed.Provider.CoSignMALog.btnCoSign_OnClick(Object sender, EventArgs e) in C:\Visual Studio MACoSignLog.aspx.cs:line 151
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

     
  •  02-03-2012, 3:22 PM 359253 in reply to 359037

    Re: Problem using PdfFileSignature with MemoryStream

    Hello  Fred,

    Thanks for using our products.

    Can you please share the source PDF document so that we can test the scenario at our end. We are really sorry for this inconvenience.

    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML