We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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

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,




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.

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)

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.