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 Jul 18, 2022 12:55 pm

Hi,

Is there any way to manually add ttf-mscorefonts-installer within the project without needing to install fonts on the linux OS?

I'm using PdfStandardsConverter Object to convert a pdf to pdf/a and it's showing "No Arial font found" error.

Code: Select all
        PdfStandardsConverter converter = new PdfStandardsConverter(new ByteArrayInputStream(content));
        converter.toPdfA1A(outputStream);



I'm using spire.pdf.free 5.1.0.

Tks.

douglas.reis
 
Posts: 3
Joined: Mon Jul 18, 2022 12:39 pm

Tue Jul 19, 2022 2:36 am

Hello,

Thanks for your inquiry.

You can refer to the code below to manually set the font folder path after getting fonts by ttf-mscorefonts-installer. If this is not what you want, please get back to me with more detailed information about your needs.

Code: Select all
PdfDocument.setCustomFontsFolders("/usr/share/fonts/truetype/msttcorefonts");
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Tue Jul 19, 2022 8:35 pm

I created a new folder called msttcorefonts inside the project and added the fonts inside it.

The No Arial Font Found error no longer happens, but now in some PDF conversions it is returning the error No 'TimesNewRoman' font found!.

Code: Select all
ERROR - class com.spire.ms.System.Exception: No 'TimesNewRoman' font found!
com.spire.pdf.packages.sprZOa.spr  (Unknown Source)
com.spire.pdf.packages.sprZOa.spr  (Unknown Source)
com.spire.pdf.packages.sprWqb.spr  (Unknown Source)
com.spire.pdf.packages.sprWqb.spr  (Unknown Source)
com.spire.pdf.packages.sprWqb.spr  (Unknown Source)
com.spire.pdf.packages.sprjmb.spr  (Unknown Source)
com.spire.pdf.packages.sprSpb.spr (Unknown Source)
com.spire.pdf.packages.sprSpb.spr  (Unknown Source)
com.spire.pdf.packages.sprSpb.spr  (Unknown Source)
com.spire.pdf.conversion.PdfStandardsConverter.toPdfA1A(Unknown Source)


Code: Select all
PdfDocument.setCustomFontsFolders("/fonts/msttcorefonts/");
        OutputStream outputStream = new ByteArrayOutputStream();
        PdfStandardsConverter converter = new PdfStandardsConverter(new ByteArrayInputStream(content));
        converter.toPdfA1A(outputStream);


Attached are the fonts I'm using.

Tks.

douglas.reis
 
Posts: 3
Joined: Mon Jul 18, 2022 12:39 pm

Wed Jul 20, 2022 8:23 am

Hi,

Thanks for your sharing.

From your code, you set a path of folder(msttcorefonts) for these fonts. But judging from the attachments you provided, you may have at least three font storage paths. The Time New Roman font exists in the "msttcorefonts 2" folder but not in the "msttcorefonts" folder. I'm not sure if this is causing the font cannot be found error. Please try to put all fonts in the same folder and set its path in the code.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed Jul 20, 2022 12:10 pm

Hi,

All fonts are in the same folder, I just separated them to attach here in the message because it only accepts attachments with up to 2mb.

tks.

douglas.reis
 
Posts: 3
Joined: Mon Jul 18, 2022 12:39 pm

Thu Jul 21, 2022 9:54 am

Hi,

Sorry for my misunderstood. Then the issue is rather strange.
I recommend that you first use the latest commercial version 8.7.0 of Spire.Pdf For Java to verify whether this issue can be resolved. If it still exists, please provide us with the PDF files related to this issue so that we can reproduce and investigate the issue further. You can upload files here or share them with us via email(support@e-iceblue.com). Thanks in advance for your assistance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF