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()
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.


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 Aspose.PDF Product Family - Free Support Forum - aspose.com

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

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

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


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


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

The issues you have found earlier (filed as PDFANDROID-632) have been fixed in Aspose.PDF for Android via Java 23.3.

I’ve tested setting the licence and it is working now. However, the first issue that I’ve encountered is still there.
The issue is “java.lang.IllegalStateException: Font Arial was not found”.

Tried the following line but still fails at .sign function.
pdfDocument.embedStandardFonts = true

Are there any alternative to this, for instance changing the font type for SignatureField? I just need to perform the .sign function on each SignatureField.

I found a similar a thread with similar issue:

For the latest android version, these only exist in the ‘com.aspose.pdf.Document’ class. The function does not exist for FontRepository.

Tried with the following:
val fontPaths = getLocalFontPaths()

fontFilePath is context.filesDir.toString(), which is the app’s files directory. I saved “Arial.tff” in that particular location.

Please advise, thank you.


Would you kindly share the problematic PDF document with which you are facing the issues? We will test the scenario in our environment and address it accordingly.

sample.pdf (35.0 KB)

I’ve attached the file to this reply.

The problem line is “sf.sign(pkcs)”



We have tested the scenario in our environment using one of our sample PFX file and did not notice any issues. The issue looks related to the missing fonts in the environment. OR API is unable to read the fonts from the directory. Please make sure that directory is accessible to the code during execution. Also, try to set font folder path like below and see if it helps:

ArrayList<String> localFontPaths = new ArrayList<String>();
localFontPaths.add(dataDir + "customfonts\\");


image.png (21.8 KB)
image2.png (62.4 KB)
image3.png (38.7 KB)

Yes, I do understand that it is missing the font. The test device that I’ve used is a Samsung S22, Arial font was not found in the device’s system folder.

I’m using the latest version of Aspose Android, the file name is “aspose-pdf-android-via-java-23.2.jar”.

FontRepository does not have the functions, getSources, setLocalFontPaths and reloadFonts.
I’ve attached 2 images to the post from Android Studio showing the functions available for FontRepository for Image1, and com.aspose.pdf.Document’s function for Image2.

To add on from my previous post that I’ve tried, it does not seem to be able to read the new path that I’ve set (I placed Arial.tff into that folder which is accessible by the application, PDF generated is being stored there)

Tried with the following:
val fontPaths = getLocalFontPaths()

fontFilePath is context.filesDir.toString(), which is the app’s files directory. I saved “Arial.tff” in that particular location.

Edit2: I did a quick test for the FontRepository function. I found a font named “CutiveMono” in the system’s font folder, and thus it did not throw an exception. However, for Arial, despite opening the font, add it in to the fontPath, still throws error.

//fontFilePath is pointing to Arial.tff
val arialFont = FontRepository.openFont(fontFilePath)
val font2 = FontRepository.findFont(“CutiveMono”)
val font3 = FontRepository.findFont(“Arial”) //Throws error.

Edit3: I’ve attached another Image in which I’ve found from SignatureField.class. This is the same exact function call, “FontRepository.findFont(“Arial”);” which throws the exception. I just need to change it to another font or somehow let FontRepository read my custom font path in Android.

java.lang.IllegalStateException: Font Arial was not found
        at com.aspose.pdf.FontRepository.findFont(Unknown Source:34)
        at com.aspose.pdf.SignatureField.m1(Unknown Source:279)
        at com.aspose.pdf.SignatureField.sign(Unknown Source:4)

Please advise, thank you.


Another investigation ticket as PDFANDROID-667 has been opened in our issue management system to investigate this issue in details. We need to analyze this issue further in order to determine its actual cause. We will soon update you on this matter once the investigation is done. We apologize for the inconvenience.


You can add Arial font for FontRepository with the method Document.addLocalFontPath

val fontFilePath = "/sdcard/Aspose/testdata/Aspose.Pdf/Fonts/arial.ttf"
val arialFont = FontRepository.openFont(fontFilePath)
val font3 = FontRepository.findFont("Arial")

Thank you for the solution. It works.