PDF Font Error - Font Not Found

Hi Team,


Environment:
Deployment is to JBoss on a Linux machine. We are using RHEL.

We’ve recently converted our PDF 4.5.1 code to 4.16.x

V4.5.1 did not work on Linux because it had issues loading Fonts. Based on forums, the suggestion was to upgrade to the latest version of the API, which we did. With V4.5.1, it would deploy and abend at Runtime when the API call was invoked.

With V4.16.x, it is failing at Deployment Time in JBoss with the following error:
Failed to instantiate [hyphen.pcs.tracker.business.service.impl.PdfDocumentServiceImpl]: Constructor threw exception; nested exception is class com.aspose.ms.System.d:
font was not found
aspose.pdf.html.HtmlWeb.getStandardFontForCodeRange(Unknown Source)
aspose.pdf.html.HtmlWeb.areAllCharsPresent_CheckExistingOrReplaceFont(Unknown Source)
com.aspose.pdf.cy.a(Unknown Source)
com.aspose.pdf.TextFragment.a(Unknown Source)
com.aspose.pdf.TextFragment.(Unknown Source)
hyphen.pcs.tracker.business.service.impl.PdfDocumentServiceImpl.(PdfDocumentServiceImpl.java:47)

My Constructor looks like this:
public PdfDocumentServiceImpl() {
List fileList = Document.getLocalFontPaths();

fileList.add("/usr/share/fonts/custom/");
Document.setLocalFontPaths(fileList);

blankLine = new TextFragment("\r\n");
blankLineSmall = new TextFragment("");
}
Please advise what I’m doing wrong.

Thanks.

Correction in Version details.


Apologies for the confusion, I meant Version 16.12.x and not Version 4.16.x.

Thanks.

Hi Team,


I’ve managed to find a resolution for this matter.
I’ve changed the Class Loading order and placed Aspose first.

I suspect that at the time Spring called the Constructors Aspose had not yet loaded.
Changing the Class Loading order did the trick for me by ensuring that no Aspose code
is called during JBoss Deployment or Class Construction.

It now works and all fonts are loading successfully.

Hi Eugene,


Thanks for contacting support and sharing your findings.

We are glad to hear that your problem is resolved. However recently we have observed similar font related issues when customers have been trying to manipulate PDF documents on non-Windows systems where fonts used inside PDF document are not installed. However for the sake of further investigation for above stated scenario, I have logged it as
PDFJAVA-36545 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time.

If possible, can you please share the code snippet and sample input PDF files for which you have been facing this problem.

We are sorry for this delay and inconvenience.

Hi Nayyer,


Thanks for your time and effort and looking into this matter.
As requested, attached please find our working source code on Windows and Linux along with the PDF produced by this source code.

I’ve added a long comment in the constructor so please be sure to read it as it gives context and an overview of how we solved the Font Loading problem for Linux.

Regards,
Eugene.

Hi Eugene,


Thanks for sharing source code. We are looking into the details and will get back to you shortly. Please be patient.


Best Regards,

Hi Eugene,


Thanks for your patience. I have checked the project which you have shared and also read your comments in the constructor. I would like to thank you for sharing your findings in such details with us. We will definitely share these details with relevant team as it would be really helpful in investigation process. Please keep using our API and if you need any assistance please feel free to let us know.


Best Regards,