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

Free Support Forum - aspose.com

Unable to Sign on PDF

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.

@developeryc

Would you please make sure that you are using a free 30-days temporary license? In case the issue is still happening, please let us know. We will further proceed to assist you accordingly.

Hello, I’m not using the 30-days temporary license yet. Just the trial version.

I’m the thread creator here. I’ve gotten a 30-days temporary license to test, but I’m having issue setting the license to the PDF License class.
I’ve tried setting license for “com.aspose.pdf.License” and “com.aspose.words.License”. Setting of the words license does not throw any error.

Below is the error:
java.lang.IllegalStateException: The license is not valid for this product. For free technical support, please post this error and the file in the Aspose.PDF Forums http://www.aspose.com/community/forums/aspose.pdf-product-family/20/showforum.aspx

Code Snipplet:
val licenceInputStream = resources.openRawResource(R.raw.license)
//Set Licence for Aspose PDF
val licence = com.aspose.pdf.License()
licence.setLicense(licenceInputStream)

My temporary license is stated as “Aspose.Total for Android via Java”

I’m using “aspose-pdf-20.11-android.via.java.jar”

@developeryca

We are checking it and will get back to you shortly.

@developeryca

We have registered an issue as PDFANDROID-632 in our issue tracking system to further investigate and rectify it. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like