Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Jun 05, 2020 3:19 pm

On linux debian 10 and openjdk11 (fontconfig is installed)

I have copied ttf fonts under /usr/share/fonts/windows

I try to convert docx to PDF.

on saveFile I have an exception
Exception in thread "main" java.lang.IllegalStateException: Cannot found font installed on the system.
at com.spire.doc.packages.sprmVA.spr (Unknown Source)
at com.spire.doc.packages.sprHSc.<init>(Unknown Source)

How to install font ?

philippe_ba
 
Posts: 6
Joined: Fri Jun 05, 2020 3:02 pm

Mon Jun 08, 2020 3:41 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Please refer to the following command to install your font. If there is any question, please provide your font file and your Word file for further investigation.
Code: Select all
     cd /usr/share/fonts/windows

     mkfontscale       

     mkfontdir           

     fc-cache -fv     


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Jun 08, 2020 9:09 am

Still the same problem under linux debian 10 - openjdk 11 - spire.doc 3.5.5

Docx is attached

My source code

Document document = new Document();

document.loadFromFile("test.docx");

//create a ToPdfParameterList object, which is used to set conversion options
ToPdfParameterList parameterList = new ToPdfParameterList();

//use PS conversion (it is faster than without PS con

parameterList.setUsePSCoversion(true);

//embed all fonts in generated PDF
parameterList.isEmbeddedAllFonts(true);
// document.setEmbedFontsInFile(true);
//auto fit the Word table so that data can be completely displayed in PDF
parameterList.setAutoFitTableLayout(true);

document.saveToFile("test.pdf", parameterList);

philippe_ba
 
Posts: 6
Joined: Fri Jun 05, 2020 3:02 pm

Mon Jun 08, 2020 10:40 am

Hello,

Thanks for your inquiry.
I suggest you copy the font file under /usr/share/fonts, then install it and try again.
Besides, our Spire.Doc supports using uninstalled font when converting Doc to PDF, as shown below, please also try it on your side. Looking forward to your further feedback.
Code: Select all
        String inputFile="data/convertedTemplate.docx";
        String fontFile="data/Calibri.ttf";
        String outputFile="output/embedNoninstalledFonts.pdf";

        Document document = new Document();
        document.loadFromFile(inputFile);

        //embed the non-installed fonts.
        ToPdfParameterList parms = new ToPdfParameterList();
        List<PrivateFontPath> fonts = new ArrayList<PrivateFontPath>();
        fonts.add(new PrivateFontPath("Calibri", fontFile));
        parms.setPrivateFontPaths(fonts);

        //save the document to a PDF file.
        document.saveToFile(outputFile, parms);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Jun 08, 2020 3:36 pm

I think the problem is with openjdk 11 and fonts configuration

The only solution is using

List<PrivateFontPath> fonts = new ArrayList<PrivateFontPath>();
fonts.add(new PrivateFontPath("Calibri", fontFile));
parms.setPrivateFontPaths(fonts);

philippe_ba
 
Posts: 6
Joined: Fri Jun 05, 2020 3:02 pm

Tue Jun 09, 2020 9:54 am

Hello,

Thanks for your feedback.
We are now configuring the test environment for further testing and I will give you an update ASAP.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Jun 10, 2020 9:56 am

Hello,

I did a series of tests and did find that there are still problems after installing the font. In response to this issue, we are considering adding a new feature to specify the path of the font, so that you only need to copy the font to the specified path without installing it. If it can be achieved in the future, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc