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

Free Support Forum - aspose.com

How to set the parameters of a signature to cover the whole pdf document?

Can you provide a sample C# to set the byte range of a signature to cover the whole pdf?



Currently the ByteRange property of a signature is readonly for the

PKCS1 signature class

PKCS7 signature class

PKCS7Detached signature class

Hi Roy,


Thanks for your inquiry. I’m afraid I couldn’t get your requirements. Could you please share some more information? So we will provide you information accordingly.

Best Regards,

Using the code attached to CryptographicException when trying to sign a PDF document



The signing of the pdf does not cover the whole document.



What parameter do I need to set for the signing to cover the whole document.



ie the return result of Aspose.Pdf.Facades.PdfFileSignature.IsCoversWholeDocument(System.String) is true when checking the signature in the signed pdf.



Hi Roy,


Thanks for sharing additional information. Please check the documentation link for details/code of adding digital signature in Pdf file. All three classes PKCS#1,PKCS#7 and PKCS#7Detachded covers whole document.

Please feel free to contact us for any further assistance.

Best Regards,

The link you provided does not show how to set the signature to cover the whole pdf document.


Aspose.Pdf.Facades.PdfFileSignature.IsCoversWholeDocument(System.String) method returns false when applied to the signed pdf.

Hi Roy,

Sorry for the inconvenience. While testing your scenario, I've added signature to a sample pdf document as described in documentation and Aspose.Pdf.Facades.PdfFileSignature.IsCoversWholeDocument(System.String) returns true. Could you please share your sample code and digital signature here? So we will test it at our end and provide you more information. For your document security you can make post private, if required.

Best Regards,

I have updated my test code to include a verify pdf function.

Demo at https://demo.pixelcom.net/Aspose/

Source at https://clients.pixelcom.net/Aspose/Aspose.zip

Hi Roy,


Thanks for sharing additional information. I’m working over your query and will update you soon.

Best Regards,

Hi Roy,


Thanks for your patience. I’ve tested your signed document at my end and IsCoversWholeDocument() method returns true. Could you please double check at your end.

Best Regards,

Using Aspose.Pdf.dll version 7.6.0.0 under .Net 3.5 & .Net 4.0; I still get false being returned by IsCoversWholeDocument() when using a windows console application. I downloaded the attached pdf & it still gave false from IsCoversWholeDocument().



The console application code is as follows:



static void Main(string[] args)

{

License lic = new License();

lic.Embedded = true;

lic.SetLicense(“Aspose.Total.lic”);

Document pdfDocument = new Document(args[0]);

PdfFileSignature pdfSign = new PdfFileSignature(pdfDocument);

Console.WriteLine(“File name: {0}”, args[0]);

Console.WriteLine(“IsContainSignature: {0}”, pdfSign.IsContainSignature());

Console.WriteLine(“TotalRevision: {0}”, pdfSign.GetTotalRevision());

IList names = pdfSign.GetSignNames();

foreach (object n in names)

{

Console.WriteLine(“Signature Name: {0}”, n.ToString());

Console.WriteLine(“CoversWholeDocument: {0}”, pdfSign.IsCoversWholeDocument(n.ToString()));

Console.WriteLine(“Revision: {0}”, pdfSign.GetRevision(n.ToString()));

Console.WriteLine(“VerifySigned: {0}”, pdfSign.VerifySigned(n.ToString()));

Console.WriteLine(“VerifySignature: {0}”, pdfSign.VerifySignature(n.ToString()));

Console.WriteLine(“Reason: {0}”, pdfSign.GetReason(n.ToString()));

Console.WriteLine(“Location: {0}”, pdfSign.GetLocation(n.ToString()));

Console.WriteLine(“Contact: {0}”, pdfSign.GetContactInfo(n.ToString()));

Console.WriteLine(“SignedAt: {0:d MMM yyyy HH:mm:ss}”, pdfSign.GetDateTime(n.ToString()));

Field f = (Field)(pdfSign.Document.Form[n.ToString()]);

Console.WriteLine(“Page: {0}”, f.PageIndex);

Console.WriteLine(“Rect: llx={0}, lly={1}, cx={2}, cy={3}”, f.Rect.LLX, f.Rect.LLY, f.Rect.Width, f.Rect.Height);

}

}

Hi Roy,


Thanks for your patience and cooperation. I’ve managed to reproduce the issue at my side and logged as PDFNEWNET-34824 in our issue tracking system for further investigation and resolution. As a work around please pass input file string to PdfFileSignature() instead Document object. However I’ve also linked your request to the logged issue and you will be notified via this thread as soon as it is resolved.


PdfFileSignature pdfSign = new PdfFileSignature(args[0]);


Best Regards,

Thanks for the workaround, but the PdfFileSignature constructor does not support a MemoryStream which is used in the primary application.



ie the following:



using (MemoryStream ms = new MemoryStream())

{

// snip load memory stream from stored encrypted data

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ms);

PdfFileSignature pdfSign = new PdfFileSignature(pdfDocument);

// snip use of pdfSign

}



I will wait for the fix.

Hi Roy,


Thank for your feedback. Sorry to know the suggested work around no use for you. However we will keep you updated about issue status via this forum thread.

Sorry for the inconvenience faced.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-34824) have been fixed in Aspose.Pdf for .NET 9.3.0.

Blog post for this release can be viewed over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.