PDFSignatureFile .SAVE method throws error using MemoryStreams

Last post 03-09-2012, 12:38 PM by nausherwan.aslam. 9 replies.
Sort Posts: Previous Next
  •  02-03-2012, 2:36 PM 359247

    PDFSignatureFile .SAVE method throws error using MemoryStreams

    I am getting this error on the current version (6.0) when trying to invoke Save method using MemoryStream:

    {"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)

     

    This was reported previously and supposedly fixed. ?????

     
  •  02-04-2012, 7:34 AM 359292 in reply to 359247

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Hello Fred,

    As requested over 359253, please share the source PDF document so that we can test the scenario at our end. We apologize for this inconvenience.

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

    Keep in touch! We're on Twitter and Facebook
     
  •  02-06-2012, 6:50 AM 359464 in reply to 359292

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Attachment: Present (inaccessible)
    As requested. A sample document is attached. During my process, I am attempting to add a second signature to each page. Previously, I was using file stream to write and then read back in to apply each second signature.
     
  •  02-10-2012, 7:31 AM 360729 in reply to 359247

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    I have same problem. I found out that problem is when you bind pdf document with memory constructor like this

    Aspose.Pdf.Kit.PdfFileSignature signature = new Aspose.Pdf.Kit.PdfFileSignature();
    signature.BindPdf (someInputMemoryStream);
    signature.Save(someOutputMemoryStream);

    but if you use

    Aspose.Pdf.Kit.PdfFileSignature signature = new Aspose.Pdf.Kit.PdfFileSignature();
    signature.BindPdf ("someInputFilePath");
    signature.Save(someOutputMemoryStream);

    it works.

    Unfortunatelly this is not solution because i have to use first constructor. Please help

     
  •  02-13-2012, 3:37 AM 360984 in reply to 360729

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Hi,

    Thank you for reporting this issue to us. I managed to reproduce this issue on my side. For the sake of correction, I have logged this issue as PDFNEWNET-33265 in our bug tracking system. Your request has also been linked to the appropriate issue and you will be notified as soon as it is resolved.

    We apologize for your inconvenience.

    Thanks & Regards,


    Rashid Ali
    Support Developer
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose – Your File Format Experts
     
  •  02-23-2012, 9:25 PM 363688 in reply to 360984

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Hi,

    Thank you for being patient.

    The issue is resolved by the development team and this issue will be a part of Aspose.Pdf for .NET v6.8 (to be released in March as per our monthly release plan) after following the complete testing and release cycle. Please be patient and we will notify you once the version is available for download.

    Sorry for the inconvenience,

    Thanks & Regards,


    Rashid Ali
    Support Developer
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose – Your File Format Experts
     
  •  03-07-2012, 8:55 AM 366448 in reply to 360729

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Hello Ivan,

    Thanks for your patience.

    In order to use MemoryStream object as an argument to PdfFileSignature.BindPdf(...) method, please try using the following code snippet. In case the problem still persists, please feel free to contact. We are sorry for your inconvenience.

    [C#]

    //create two file streams to read pdf files
    FileStream fs1 = new FileStream(@"d:\pdftest\SamplePDF.pdf", FileMode.Open, FileAccess.Read);
    //create byte arrays to keep the contents of PDF files
    byte[] buffer1 = new byte[Convert
    .ToInt32(fs1.Length)];
    // read the contents of Stream into Byte array
    fs1.Read(buffer1, 0, buffer1.Length);
    // create MemoryStream object
    MemoryStream ms = new MemoryStream
    (buffer1);
    // create PdfFileSignature object
    Aspose.Pdf.Facades.PdfFileSignature signature = new PdfFileSignature
    ();
    signature.BindPdf(ms);
    // save the update document
    signature.Save(@"d:\pdftest\SamplePDF-output.pdf");


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

    Keep in touch! We're on Twitter and Facebook
     
  •  03-07-2012, 2:57 PM 366538 in reply to 359247

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Thanks for your patience. Please note that the issues you have found earlier (filed as PDFNEWNET-33265) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
  •  03-09-2012, 7:58 AM 367108 in reply to 366538

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    That release is for Aspose.PDF. I am using the Aspose.PDF.Kit application. What is the status for release of that Version?
     
  •  03-09-2012, 12:38 PM 367152 in reply to 367108

    Re: PDFSignatureFile .SAVE method throws error using MemoryStreams

    Hi,

    I would like to inform you that Aspose.Pdf for .NET and Aspose.Pdf.Kit for .NET have been merged into a single product and Aspose.Pdf.Kit for .NET has been discontinued as a separate product. All the features of Aspose.Pdf.Kit for .NET are available under Aspose.Pdf.Facades namespace of Aspose.Pdf for .NET v6.x. No further modifications / Fixes will be done for Aspose.Pdf.Kit for .NET and no more releases will be there for Aspose.Pdf.Kit for .NET. Please download and try the latest version of Aspose.Pdf for .NET v6.8. You can check the following documentation links to upgrade your code from Aspose.Pdf.Kit for .NET to the new merged Aspose.Pdf for .NET.

    http://www.aspose.com/blogs/aspose-blogs/shahzad-latif/archive/2011/06/11/migrating-from-legacy-code-to-merged-aspose.pdf-for-.net.html

    http://docs.aspose.com/display/pdfnet/Migration+from+Aspose.Pdf.Kit

    You may get a 30 days temporary license to evaluate your required features of Aspose.Pdf. Please use the below link to acquire a temporary license (choose “Get a Temporary License” option).

    http://www.aspose.com/purchase/default.aspx

     

    Please feel free to contact support in case you need any further assistance.

    Sorry for the inconvenience,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
View as RSS news feed in XML