Digital signature pdf - Android

Hi, Does Aspose have methods in Android to digitally sign PDF documents using a PKCS#12 file (a *.pfx or *.p12 file)?

Thanks,

Eliana

Hi Eliana,


Thanks for contacting support.

You can digitally sign PDF files using Aspose.Pdf for Android. Please try using following code snippet and in case you encounter any issue, please feel free to contact.

[Java]

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

//Instantiate Document object

com.aspose.pdf.Document doc = new com.aspose.pdf.Document();

//Add a page to PDF document

doc.getPages().add();

OutputStream out = new java.io.ByteArrayOutputStream();

//Save document to Stream object

doc.save(out);

//Create PdfFileSignature instance

com.aspose.pdf.facades.PdfFileSignature pdfSignSingle = new com.aspose.pdf.facades.PdfFileSignature();

//Bind the source PDF by reading contents of Stream

pdfSignSingle.bindPdf(new ByteArrayInputStream(((ByteArrayOutputStream)out).toByteArray()));

//Sign the PDF file using PKCS1 object

pdfSignSingle.sign("Digial Signature", new PKCS1(dataDir + "VirtualCabinetPortal (1).pfx", "password"));

//Set image for signature appearance

pdfSignSingle.setSignatureAppearance(dataDir+"im.jpg");

//Save final output

pdfSignSingle.save(dataDir+“Signed_Copy.pdf”);