Certify a PDF document

Hello,

When a certify a Word document for PDF Adobe Reader is not accepting the certification.

I have tried to certify (.pfx) a document with Aspose.PDF.

And I can’t find the documentation on how to do this.

Can you please tell me how to certify a PDF document.

re Bert
Hello re Bert,

Thanks for using our API's.

Please check the link for the documentation

Add Digital Signature in a PDF File

Best Regards,



Hello

the answer is not what I expected.
I have a pfx file (certificate) and need to sign a PDF.

So when I send a pdf they can see that the original is from us.

re

Hello re Bert,


p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

Thanks for your inquiry. Please use the below sample code for setting a certificate to a PDF document.


const string myDir = @"c:/Downloads/";
PdfFileSignature pdfVerify = new PdfFileSignature();
//bind input PDF file
pdfVerify.BindPdf(myDir + @"Google.pdf");
pdfVerify.SetCertificate(myDir + @"MySPC.pfx", "test"); // Set certificate
pdfVerify.Sign(1, "Reason", "Contact", "Location", true, new System.Drawing.Rectangle(10, 10, 50, 50)); // Sign the document with MySPC.pfx file
pdfVerify.Save(myDir + @"Google_Certified.pdf");
Console.WriteLine("Signed File Created!");

If you still face any issue, Please feel free to contact us.


Best Regards,

Hello,

I am still not there were I would like to be
this is what I want:

internal bool SignWordPDF(string inputWord, string outputPdf, string pfx)
{

Aspose.Words.Document doc = new Aspose.Words.Document(FilePath(inputWord));
using (var streamout = new MemoryStream())
{
using (var certFileStream = new FileStream(FilePath(pfx), FileMode.Open, FileAccess.Read))
{
var certificateBytes = new byte[certFileStream.Length];
certFileStream.Read(certificateBytes, 0, certificateBytes.Length);

var cert = new X509Certificate2(certificateBytes, “itissafe@3su”);
var encrdetails = new PdfEncryptionDetails(string.Empty, “Triples3861”, PdfEncryptionAlgorithm.RC4_128);
encrdetails.Permissions = PdfPermissions.DisallowAll | PdfPermissions.HighResolutionPrinting | PdfPermissions.Printing;

var options = new PdfSaveOptions { Compliance = PdfCompliance.PdfA1b };

// Set this object in the options.
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(cert, “Dit document kan niet gewijzigd worden tijdens of na verzending.”, “BizTrack”, DateTime.Now);
options.EncryptionDetails = encrdetails;

doc.Save(FilePath(outputPdf), options);
}

return true;
}

}

however when saving the file I get the following:
You have requested both PDF/A compliance and PDF encryption but these options cannot be used together

The below is working

internal bool SignWordPDF(string inputWord, string outputPdf, string pfx)
{

Aspose.Words.Document doc = new Aspose.Words.Document(FilePath(inputWord));
using (var streamout = new MemoryStream())
{
using (var certFileStream = new FileStream(FilePath(pfx), FileMode.Open, FileAccess.Read))
{
var certificateBytes = new byte[certFileStream.Length];
certFileStream.Read(certificateBytes, 0, certificateBytes.Length);

var cert = new X509Certificate2(certificateBytes, “itissafe@3su”);
//var encrdetails = new PdfEncryptionDetails(string.Empty, “Triples3861”, PdfEncryptionAlgorithm.RC4_128);
//encrdetails.Permissions = PdfPermissions.DisallowAll | PdfPermissions.HighResolutionPrinting | PdfPermissions.Printing;

var options = new PdfSaveOptions { Compliance = PdfCompliance.PdfA1b };

// Set this object in the options.
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(cert, “Dit document kan niet gewijzigd worden tijdens of na verzending.”, “BizTrack”, DateTime.Now);
//options.EncryptionDetails = encrdetails;

doc.Save(FilePath(outputPdf), options);
}

return true;
}

}:

but then I can’t set the permissions:
PdfPermissions.DisallowAll | PdfPermissions.HighResolutionPrinting | PdfPermissions.Printing;

so maybe you know the answer

re

Hi Bert,

Thanks for your inquiry.

Please check: Working with Digital Signatures using Aspose.Words for .NET

If you need both above features, please use the following C# code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Test Signed PDF.");

PdfEncryptionDetails encrdetails = new PdfEncryptionDetails(
                                            string.Empty,
                                            "Triples3861",
                                            PdfEncryptionAlgorithm.RC4_128);

encrdetails.Permissions = PdfPermissions.DisallowAll |
                            PdfPermissions.HighResolutionPrinting |
                            PdfPermissions.Printing;

CertificateHolder cert = CertificateHolder.Create(MyDir + "signature.pfx", "password");

PdfSaveOptions options = new PdfSaveOptions();
options.Compliance = PdfCompliance.Pdf15;
options.EncryptionDetails = encrdetails;
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(
                                            cert,
                                            "reason",
                                            "location",
                                            DateTime.Now);

doc.Save(MyDir + @"17.1.0.pdf", options);

Hope, this helps.
Best regards,