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

Free Support Forum - aspose.com

Need Java Create /Validate PDF digital signature sample

Good Morning,

I have download the trail version of "aspose-pdf-kit-4.6.0-java" forlder for PDF creation and signature validation. There is no Java files available in this KIT.

Could you please share the download link for the same to try the samples.

Thanks in Advance.

Regards,

Babu S.

Hi Babu,


Thanks for contacting support.

In order to add digital signature to existing PDF file using Aspose.Pdf.Kit for Java, please try using the following code snippet.

[Java]

//create PdfFileSecurity object and
bind input and output files
<o:p></o:p>

String inputFile = "c:/pdftest/EMF_test.pdf";

String certificateFile = "c:/pdftest/VirtualCabinetPortal.pfx"; ;

com.aspose.pdf.kit.PdfFileSignature pFileSignature = new com.aspose.pdf.kit.PdfFileSignature();

//create Signature object

com.aspose.pdf.kit.Signature sgn = new com.aspose.pdf.kit.Signature();

sgn.setLocation("sydney");

sgn.setName("Aspose");

sgn.setReason("conform myself");

sgn.setRect(new java.awt.Rectangle(100, 100, 200, 200));

pFileSignature.bindPdf(inputFile);

//sign PDF file

pFileSignature.setCertificateFile(certificateFile);

pFileSignature.setMultiSignature(true);

pFileSignature.setSignModel(pFileSignature.SELF);

pFileSignature.setPageNumber(1);

pFileSignature.setPassword("password");

pFileSignature.setSignature(sgn);

pFileSignature.setKeyStoreType("pkcs12");

pFileSignature.setSignatureAppearance("c:/pdftest/test.png");

pFileSignature.setCertificationLevel(pFileSignature.NOT_CERTIFIED);

java.io.FileOutputStream outStream = new java.io.FileOutputStream("c:/pdftest/Signature_output.pdf");

pFileSignature.save(outStream);

Hi Babu,


Adding more to my previous comments, please note that since April-2013, Aspose.Pdf.Kit for Java has been merged into Aspose.Pdf for Java and the release of Aspose.Pdf.Kit for Java as a separate component will be discontinued in Q3-2013. However the current release of Aspose.Pdf for Java cannot sign PDF document using code snippet shared earlier. The problem is logged as PDFNEWJAVA-33589 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction.

You may consider visiting the following links for further details on

Hi Babu,


Thanks for your patience.

We are pleased to share that the issue PDFNEWJAVA-33589 reported earlier is resolved and its fix will be included in next release of Aspose.Pdf for Java. In order to sign the PDF files, please try using the following code snippet.

[Java]

String dataDir = “D:\temp\”;<o:p></o:p>

String inputFile = dataDir + "HelloWorld.pdf";

String outSignedFile = dataDir + "out_PDFNEWJAVA_33589.pdf";

PdfFileSignature pFileSignature = new PdfFileSignature();

pFileSignature.bindPdf(inputFile);

//adding signature

pFileSignature.sign(1, "conform myself", "", "sydney", true, new java.awt.Rectangle(100, 200, 200, 100), new PKCS1(dataDir + "VirtualCabinetPortal (1).pfx", "password"));

pFileSignature.setSignatureAppearance(dataDir + "im.png");//using signature image

java.io.FileOutputStream outStream = new java.io.FileOutputStream(outSignedFile);

pFileSignature.save(outStream);

The issues you have found earlier (filed as PDFNEWJAVA-33589) have been fixed in Aspose.Pdf for Java 9.5.0.


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