Error signing documents

Hi,

#fff” title=”" closure_uid_2o2eoz=“296” pc=“A) Funciona correctamente, pasamos el documento de entrada como ruta de fichero.” qc="A) Works fine, we pass the input document as a file path.

“>A) Works fine, we pass the input document as a file path.

<SPAN style=“BACKGROUND-COLOR: #fff” title=”" closure_uid_2o2eoz=“296” pc=“A) Funciona correctamente, pasamos el documento de entrada como ruta de fichero.” qc="A) Works fine, we pass the input document as a file path.

">

private byte[] Sign_Document(Pkcs7Signature signature)

{

using (MemoryStream strOutputDoc = new MemoryStream())

{

PdfFileSignature pdfSignature = new PdfFileSignature();

pdfSignature.BindPdf(@"c:\directory\file.pdf");

pdfSignature.Sign(1, "reason", "contact", "location", false, new Rectangle(0, 0, 150, 100), signature);

pdfSignature.Save(strOutputDoc);

return strOutputDoc.ToArray();

}

}



#fff” title=”" closure_uid_2o2eoz=“297” pc=“B) No funciona correctamente, pasamos el documento de entrada como flujo de datos.” qc="B) Not working properly, we as the input document data stream.

">

private byte[] Sign_Document(byte[] document, Pkcs7Signature signature)

{

using (MemoryStream strInputDoc = new MemoryStream(document))

using (MemoryStream strOutputDoc = new MemoryStream())

{

PdfFileSignature pdfSignature = new PdfFileSignature();

pdfSignature.BindPdf(strInputDoc);

pdfSignature.Sign(1, "reason", "contact", "location", false, new Rectangle(0, 0, 150, 100), signature);

pdfSignature.Save(strOutputDoc);

return strOutputDoc.ToArray();

}

}


We need to sign documents in either form A or form B.

Regards,

Hi Manel,

I’m unable to see you passing the Signature or Certificate instance to the PdffileSignature constructor or Sign method. Can you please try using the appropriate overload from this list? Also, can you please make sure that you’re using the latest version of the component?

If you still find the same issue then please share the sample input files (PDF and Certificate) along with the complete code snippet or a small sample application which can help us reproduce the issue at our end?

We’re sorry for the inconvenience.
Regards,

Hi,

Sorry, I corrected the above post code, the method Sign. It was a mistake by passing the sample code.

Regards,

Hi Manel,

Can you please confirm that this issue is resolved at your?

Regards,

Hi,

I corrected the example code but the problem is not solved.

Regards,

Hi Manel,

Please share the sample input PDF and Certificate files so we could test the issue at our end using your particular scenario. Moreover, please share what problem you’re facing at your end while signing the PDF file?

We’re sorry for the inconvenience.
Regards,