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,
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”);