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 30, 2024 3:11 pm

Dear support team,

we encounter other problems when converting a docx file to a pdf file using Spire.Doc for Java. We use most current version (12.1.16) but the problem occurrs using older versions, too.

However, Microsoft Word creates a correct pdf file.

Please find attached the docx file used for the test, the pdf file created by Spire.Doc and the pdf file created by Microsoft Word. Concerning the test code and my environment, please have a look at my previous issue "Cannot found font installed on the system" (SPIREDOC-10283).

Kind regards,
Marcus

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

Wed Jan 31, 2024 2:28 am

Hello,

Thank you for your inquiry.
I have received your inquiry and have tested the Word document you provided. After thorough investigation, I have identified the issue you mentioned. It appears that the absence of the required font is causing this problem, despite the fact that the Word document is set to embed the font into the document. Upon closer examination, it seems that the Chinese characters are not being properly embedded.
To address this issue, I have used the following code to test and resolve the problem. Additionally, I have attached the test results file from my Linux environment to this email for your reference.
Code: Select all
//The Fonts folder contains two font files, calibri.ttf and Deng.ttf.
Document.setGlobalCustomFontsFolders("Fonts");
Document document = new Document();
document.loadFromFile("Test.docx");
document.saveToFile("Test.generated-nofonts.pdf", FileFormat.PDF);

Please note that this code has been tested and verified to resolve the embedding issue for the Chinese characters in your Word document.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Jan 31, 2024 8:17 am

Hi Annika,

you mean the issue with the chinese characters has the same cause as addressed by SPIREDOC-10283?
Problem is that our application that uses your library is a multi-language application and we do not know in advance which fonts and special characters are used. So it is no option for us to deliver all the fonts within our application (simply because the design of the document templates (docx files) is done by our customers and not by us) to ensure PDF generation works correctly. Hence, we have to trust that fonts embedding into the docx file works as expected.

So needing a fix for this issue very soon is crucial for us.

Regards,
Marcus

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

Thu Feb 01, 2024 1:50 am

Hello,

Thank you for your feedback.
The issue you mentioned in this post is caused by the font embedded in the Word document that does not support Chinese characters. After parsing the Word document, we found that the font used is "Verdana Pro" (as shown in the screenshot), which has been confirmed by our developers to not support Chinese characters.
When viewed in Microsoft Word, Chinese characters display normally because Microsoft Word uses a default font that supports Chinese characters to display them. However, when we use Spire.Doc to convert Word to PDF, it first searches the system for the font used in the document. If the system does not have the font, it will search for a substitute font that supports the characters. If there is no substitute font, the program will either report an error or result in garbled text.
According to your previous description, your environment cannot install fonts, so I proposed using the method of loading a custom font path to solve the issue of Chinese characters displaying as garbled text.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Feb 06, 2024 9:57 pm

Good evening!

First of all thank you for the explanation. However, I do not understand why the font that is capable to display chinese characters correctly is not embedded into the Word document (the docx file), too. Can I enforce it as the designer of a Word document? As I mentioned we can not provide all the fonts used in Word documents on the server side, simply because we do not know the Word documents uploaded to our web application in advance.

Another question: Afaik docx is nothing else than a zip archive containing multiple folders an files. Were can I find the information which fonts are embedded in a docx file?

Kind regards,
Marcus

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

Wed Feb 07, 2024 1:51 am

Hello,

Thank you for your feedback.
Yes, the default Chinese fonts are forced to be used in Microsoft Word when the set fonts do not support Chinese. However, the default Chinese font in Microsoft Word is different for everyone's installation, usually SimSun or DengXian.
In addition, the .docx file can be opened using 7-Zip, and then extract the file to the specified folder, and finally in the word folder, open the "document.xml" will be able to see the Word document for each TextRange fonts used.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Feb 07, 2024 8:00 am

Hello Annika,

if I understand you correctly, if I use a font in my document that does not support chinese (or other special) characters, Word automatically chooses a font behind the scenes to display these characters correctly and this font is never embedded into the document even if the setting to embedd fonts is enabled?

Again the question: Do I have any means to embed this chinese font even if I use a font that does not support chinese characters (like Verdana Pro in my case)?

Regards,
Marcus

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

Wed Feb 07, 2024 9:09 am

Hello,

Thank you for your feedback.
Yes, this is generally the case because the Microsoft Word software is installed with some font files embedded, but if the Word document is not topped to use these fonts then setting the embedded fonts into the document will not embed these fonts into the document.
In addition, when you set up in Word does not support Chinese fonts, but in the settings of the embedded fonts this does not support Chinese fonts will still be embedded in the Word document. But when you save after opening this document to view, you will find that Microsoft Word on the display of this Chinese font is not what you set, but parse the Word document will find embedded in the font is what you set.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Feb 07, 2024 12:12 pm

Hi Annika,

I discovered that all fonts embedded into a document are listed in the file "word/fontTable.xml" and the respective obfuscated fonts are contained in folder "word/fonts". These information help a lot as we now have the possibility to check which fonts are really embedded and which ones are missing. To include the missing fonts we add a single hidden character for each font missing into our document template. By this workaround we can ensure the required fonts are actually embedded into the document.

Thank you very much for your support on the "tricky" topic.

Regards,
Marcus

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

Thu Feb 08, 2024 6:51 am

Hello,

You’re welcome. Thanks for your feedback.
If you encounter any issue in the future with Spire, just feel free to contact us!


Sincerely,
Annika
E-iceblue support team
User avatar

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

Mon Feb 12, 2024 10:55 am

Dear Annika,

I'm sorry but I have to reopen this issue.

The docx file now embeds all fonts used in the document. I checked the docx archive and it looks ok to me ("fontTable.xml" lists all used fonts and subfolder "fonts" contains all odttf-files).

However, Spire.Doc for Java 12.1.16 still does not generate a correct pdf file. There are still characters missing or displayed as boxes.
Please find all files in the attached file "Test.zip". The docx file is not included as it is to large (due to the embedded fonts) and rejected by your upload filter. I will send it to you by mail.

And ideas what I can do?

Regards,
Marcus

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

Tue Feb 13, 2024 2:25 am

Hello,

Thank you for the information.
I tested your Word document on windows and reproduced the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREDOC-10310. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Feb 12, 2025 10:45 am

Dear support team,

we are waiting for a resolution of this issue for exactly one year now. It's really disappointing that we still have not bug fix yet. How is the current status of this issue, please?

Regards,
Marcus

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

Thu Feb 13, 2025 6:42 am

Dear Marcus,

Thanks for your patient waiting.
Our latest Spire.Doc Version 13.1.3 contains the fix of your issue. Meanwhile, as the font Verdana used in your document does not support certain characters, please install this font (Arial Unicode MS) on your system to ensure all characters in your document can be rendered after conversion. If there is any question, please feel free to write back.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Thu Feb 13, 2025 8:36 am

Hi Nina,

if it is resolved, I wonder why SPIREDOC-10310 is not listed in the version news:
https://www.e-iceblue.com/news/Spire.Do ... 3.1.3.html

Is there somewhere a possibilty to enter an issue number, e. g. SPIREDOC-10310, and get the answer whether the issue is resolved and if yes in which Spire.Doc for Java version?

Regards,
Marcus

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

Return to Spire.Doc