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.

Tue Jan 23, 2024 1:13 pm

Hello support team,

we just updated Spire.Doc for Java from version 11.7.0 to 12.1.10 and experience some serious error concerning the generation of PDF documents.

Code: Select all
Caused by: java.lang.IllegalStateException: Cannot found font installed on the system.
   at com.spire.doc.packages.sprnyi.spr╇┎(Unknown Source)
   at com.spire.doc.packages.sprobj.spr▍┑(Unknown Source)
   at com.spire.doc.packages.sprobj.spr–┒(Unknown Source)
   at com.spire.doc.packages.sprobj.spr╸©(Unknown Source)
   at com.spire.doc.packages.sprehj.spr⌫┏(Unknown Source)
   at com.spire.doc.packages.sprehj.spr┨┏(Unknown Source)
   at com.spire.doc.packages.sprlku.<init>(Unknown Source)
   at com.spire.doc.packages.sprlvu.<init>(Unknown Source)
   at com.spire.doc.packages.sprrxr.<init>(Unknown Source)
   at com.spire.doc.Document.spr⑇┌—(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr▌◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr℉◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr⅟◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr┨◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr▉◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr⌫●(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr╃◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr┎◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr┤●(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr◍◐(Unknown Source)
   at com.spire.doc.packages.sprtxr.spr┖●(Unknown Source)
   at com.spire.doc.packages.sprcis.spr™▢(Unknown Source)
   at com.spire.doc.packages.sprcis.spr™ㆀ(Unknown Source)
   at com.spire.doc.packages.spryqs.spr⌾℉(Unknown Source)
   at com.spire.doc.packages.spryqs.spr╅℃(Unknown Source)
   at com.spire.doc.packages.spryqs.spr┊℃(Unknown Source)
   at com.spire.doc.packages.spryqs.spr†■(Unknown Source)
   at com.spire.doc.packages.sprdnr.spr∫▕(Unknown Source)
   at com.spire.doc.Document.spr└┐—(Unknown Source)
   at com.spire.doc.Document.updatePageLayout(Unknown Source)
   at com.spire.doc.Document.sprℂ┐—(Unknown Source)
   at com.spire.doc.Document.spr│┐—(Unknown Source)
   at com.spire.doc.packages.sprmqw.spr┡⌭—(Unknown Source)
   at com.spire.doc.packages.sprmqw.spr┰⌭—(Unknown Source)
   at com.spire.doc.packages.sprmqw.spr®‘(Unknown Source)
   at com.spire.doc.Document.spr•┍—(Unknown Source)
   at com.spire.doc.Document.spr┦┌—(Unknown Source)
   at com.spire.doc.Document.saveToStream(Unknown Source)


Currently we are forced to downgrade to version 11.12.1 as the error does not occurr there. However, we want to use the newly added chart feature which is available since 12.1.0.

I have been able to reduce our generation code to the bare minimum to make it easier for you to (hopefully) reproduce the error:

Code: Select all
java.util.Locale.setDefault(java.util.Locale.ROOT);
try (
        InputStream stream = new ByteArrayInputStream(org.apache.commons.io.FileUtils.readFileToByteArray(new File("Test.docx")));
        FileOutputStream outputStream = new FileOutputStream("Test.generated.pdf")
) {
    Document document = new Document(stream);
    document.setReplaceFirst(true);
    document.createMinialDocument();
    String tempFilePath = System.getProperty("java.io.tmpdir") + UUID.randomUUID() + ".Docx";
    document.saveToFile(tempFilePath, FileFormat.Docx);
    Document generatedDocument = new Document(tempFilePath);
    ToPdfParameterList toPdfParameterList = new ToPdfParameterList();
    toPdfParameterList.setPrivateFontPaths(new ArrayList<>());
    generatedDocument.saveToStream(outputStream, toPdfParameterList);
} catch (Exception ex) {
    throw new RuntimeException(ex);
}


I also prepared a docx file (Test.docx) to be used for testing.
Please note that the setting to embed used fonts is enabled so that the document looks exactly the same when it is generated on the server even if the fonts used by the designer are not installed on the server.

We use OpenJDK 11 on our Ubuntu server:
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

I really hope we will get a bugfix soon as the latest version has some required bug fixes and the new chart feature.

mgattinger
 
Posts: 65
Joined: Fri May 21, 2021 9:03 am

Wed Jan 24, 2024 3:02 am

Hello,

Thank you for your inquiry.
I have tested your document usingSpire.Doc for Java Version: 12.1.10 on Ubuntu 20.04, but I was unable to reproduce the issue you mentioned. I have attached my test project's JAR file, which includes the resulting document. Please download it and conduct the test in your environment.
If the issue persists after testing, kindly provide detailed information about your Ubuntu environment. Thanks in advance.
With this information, we will be able to investigate the issue further and provide you with a solution. Thank you for your cooperation.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Jan 25, 2024 12:48 pm

I further simplified the code to reproduce the exception:

Code: Select all
package ...;

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.license.LicenseProvider; // Spire.Doc for Java 11.12.1
//import com.spire.doc.license.LicenseProvider; // Spire.Doc for Java 12.1.0
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;

import org.apache.commons.io.FileUtils;

public class Main {
    public static void main(String[] args) {
        LicenseProvider.setLicenseKey("...");
        try (InputStream inputStream = new ByteArrayInputStream(FileUtils.readFileToByteArray(new File("Test.docx")))) {
            try (FileOutputStream outputStream = new FileOutputStream("Test.generated.pdf")) {
                Document document = new Document(inputStream);
                String tempFilePath = System.getProperty("java.io.tmpdir") + "/" + UUID.randomUUID() + ".Docx";
                document.saveToFile(tempFilePath, FileFormat.Docx);
                Document generatedDocument = new Document(tempFilePath);
                generatedDocument.saveToStream(outputStream, FileFormat.PDF);
            }
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}


While this code works fine using Spire.Doc for Java 11.12.1 it fails using Spire.Doc for Java 12.1.0 (and as well using version 12.1.10) with the known exception.

Please let me know which further details you need about my Ubuntu environment.

Regards,
Marcus

mgattinger
 
Posts: 65
Joined: Fri May 21, 2021 9:03 am

Fri Jan 26, 2024 8:58 am

Hello,

Thank you for your feedback.
I have tested your code using the recently released Spire.Doc for Java Version 12.1.16, but I was unable to reproduce the issue you mentioned.
I kindly request you to upgrade to this version and ensure that the font used in the Word document is installed in your testing environment before conducting another test.
If the problem persists after retesting, please provide me with your testing project that can reproduce the issue and also provide detailed information about your Ubuntu version. You could attach them here or send them to us via email ([email protected]). Thanks in advance.
We are committed to resolving any issues you may encounter, and we appreciate your cooperation in providing us with the necessary details for further investigation.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Fri Jan 26, 2024 11:57 am

Greetings, Annika!

Unfortunately the problem still exists using the latest version 12.1.16.
I've sent the IntelliJ project to the support mail address.

Please note, that there are no fonts explicitly installed on the server.
As I already mentioned the fonts used in the document are embedded into the document itself (using the respective setting in Microsoft Word) - see screenshot I've already attached before.

Regards,
Marcus

mgattinger
 
Posts: 65
Joined: Fri May 21, 2021 9:03 am

Mon Jan 29, 2024 6:37 am

Hello,

Thank you for providing detailed information via email.
I have loaded the project you provided using IDEA and packaged it into a JAR file. I then uploaded it to an Ubuntu environment for testing, but I was unable to reproduce the issue you mentioned. Furthermore, I have confirmed that the required fonts specified in your Word document are not installed in my testing environment.
After consulting with my colleagues, we believe that the error you encountered may be due to the absence of the "Arial," "Calibri," and "Cambria" fonts in your testing environment. Although these fonts are not explicitly used in the Word document, sometimes program errors can occur when these fonts are missing. Therefore, I kindly request you to install these three fonts and conduct the test again.
Please let us know the results of your testing after installing the fonts. We look forward to your feedback.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Return to Spire.Doc