Hello, I’m using Aspose Android via Java, version 20.11 from here:
I’ve successfully generated a PDF with SignatureField but when I try to perform the sign function, I get the following error:
“java.lang.IllegalStateException: Font Arial was not found”
I saw various solutions but the android version’s FontRepository class only has 4 function (2 openFont, 2 findFont).
Here’s my code snipplet (In kotlin)
for (field in pdfDocument.form.fields) {
val sf = field as SignatureField
val certFilePath = this.context!!.filesDir.toString() + “/cert.pfx”
val file = File(certFilePath)
val certInputStream = context!!.assets.open(“test.pfx”)
Files.copy(certInputStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING)
val pkcs = PKCS7(certFilePath, “testpfxpassword”)
val signedImage = resources.openRawResource(R.drawable.signed) //Signed is just an image.
pkcs.date = DateTime.getNow()
pkcs.setImage(signedImage)
sf.sign(pkcs) // This line throws the exception.
}
When I tried to embed the standard fonts with the following line of code:
pdfDocument.embedStandardFonts = true
I get another error :
java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean com.aspose.pdf.ADocument.get_IsObjectLicensed()’ on a null object reference
I’m running on the evaluation version.
Please assist. Thank you.