Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jan 15, 2024 4:21 pm

Hello,

I am currently working on a project where I'm utilizing Spire.PDF, and I've come across a situation that I'd like some guidance on.

In my application, there are instances where a font specified in a method may not be installed on the system (in my specific case, I use "saveToFile" to generate a SVG per PDF page), leading to a "com.spire.ms.System.Exception: No font found!" exception.

Is there a recommended approach or a specific method to avoid this exception and use a default font gracefully?

Any insights or code snippets would be greatly appreciated. Thank you in advance for your assistance!

Best regards.

rubensalado
 
Posts: 9
Joined: Mon Sep 04, 2023 8:47 am

Tue Jan 16, 2024 2:51 am

Hello,

Thank you for your inquiry.
Based on your description, I would recommend using the approach of loading a font file to address the issue you encountered. Please refer to the sample code provided below as a reference:
Code: Select all
//Load a custom font folder("F:\\Fonts" is the path to the fonts folder)
PdfDocument.setCustomFontsFolders("F:\\Fonts");
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.loadFromFile("input.pdf");
or
// Create a new instance of PdfTrueTypeFont with the specified font file path, font size, and embedding flag
PdfTrueTypeFont font = new PdfTrueTypeFont("F:\\Fonts\\arial.ttf",12f,true);

If you have any further questions or need additional assistance, please feel free to reach out to us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Sep 13, 2024 9:14 am

Hi,

Is there a way to replace the font that is missing by another font in the selected location?

CerealPT
 
Posts: 3
Joined: Thu Aug 22, 2024 2:15 pm

Sat Sep 14, 2024 5:31 am

Hello,CerealPT

Thanks for your inquiry. At present, we do not support setting alternative fonts directly. If the used font is not found in the system, our product defaults to finding a font that supports this glyph instead. Thus, it is recommended that you ensure that there are some commonly used fonts installed on your system. If you are in a Linux environment, you can copy and install the commonly used fonts of the Windows system.
If you have any other questions, please feel free to write to me.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 277
Joined: Mon Jul 15, 2024 5:40 am

Tue Sep 17, 2024 2:14 pm

Amin.Gan wrote:Hello,CerealPT

Thanks for your inquiry. At present, we do not support setting alternative fonts directly. If the used font is not found in the system, our product defaults to finding a font that supports this glyph instead. Thus, it is recommended that you ensure that there are some commonly used fonts installed on your system. If you are in a Linux environment, you can copy and install the commonly used fonts of the Windows system.
If you have any other questions, please feel free to write to me.

Sincerely,
Amin
E-iceblue support team


Hi Amin!
Thanks for your answer.
I am having the following error while running code to convert a pdf to pdf/a:

Error Message: class com.spire.ms.System.Exception: No '' font found!
com.spire.pdf.packages.sprhpf.spr┝⌺(Unknown Source)
com.spire.pdf.packages.sprhpf.spr︼⌻(Unknown Source)
com.spire.pdf.packages.sprpwo.spr®▁(Unknown Source)
com.spire.pdf.packages.sprpwo.spr┈╽(Unknown Source)
com.spire.pdf.packages.sprpwo.spr⅝╽(Unknown Source)
com.spire.pdf.packages.sprnyo.spr┖╾(Unknown Source)
com.spire.pdf.packages.spryuo.spr┪▀(Unknown Source)
com.spire.pdf.packages.spryuo.spr▢▀(Unknown Source)
com.spire.pdf.packages.spryuo.spr〨▀(Unknown Source)
com.spire.pdf.conversion.PdfStandardsConverter.toPdfA1B(Unknown Source)
...

This code is running in an AWS Lambda function.
If I run this code locally in my machine, it is correctly converted.
I also used the PdfDocument.setCustomFontsFolders(folder) in order to point to a folder that contains all the fonts that I'm currently using: it works in my mac but fails in AWS Lambda.
In my mac, I also did the test to point to an empty folder and the conversion was successful --> How is this possible?

Did you already face this problem?

Thanks a lot for your support!

CerealPT
 
Posts: 3
Joined: Thu Aug 22, 2024 2:15 pm

Wed Sep 18, 2024 7:21 am

Hello,CerealPT

Thanks for your feedback. when you deploy the program on AWS Lambda and use 'PdfDocument.setCustomFontsFolders(folder)', please ensure that the program has access to the font files. If the problem is still not resolved, please provide us with your input PDF document for investigation. You can upload here or send it to us via email( support@e-iceblue.com ). Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 277
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF