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.

Mon Jan 22, 2024 1:08 pm

Hi,
After upgrade to SpireDoc 12.1.0, we getting wrong text in Hebrew in pdf file.
Conversion done by code:
Code: Select all
document.saveToFile(outputPdfFile.getAbsolutePath(), FileFormat.PDF);


Before upgrade all was ok.

Please see attached files.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Tue Jan 23, 2024 3:14 am

Hello,

Thank you for your inquiry.
I have tested the Word document you provided, but I was unable to reproduce the issue you mentioned. I have attached the result file from my testing for your reference.
Furthermore, I examined the embedded fonts in the PDF file you provided and found that the font used is not Calibri. However, the Word source document specifies Calibri as the font. Therefore, I kindly suggest checking your testing environment for the presence of the Calibri font. If it is not installed, please install it before conducting further tests. If the font is already installed, please ensure that you have the necessary permissions to access the font file.
If you require any additional assistance or have further questions, please feel free to reach out.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Jan 23, 2024 8:52 am

Hi,
Thanks for quick answer.
This issue happen as part of regression tests. With old library (11.7.0) we don't see issue, problem appear only after upgrade to 12.1.0. Code executed on same environment, just library was changed.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Tue Jan 23, 2024 9:18 am

Hello,

Thank you for your feedback.
We appreciate your cooperation in helping us investigate the issue further. In order to assist you better, could you please provide the following information. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.
1) Your complete test code.
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
3) The JDK version you are using, such as JDK1.8.0.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Sun Jan 28, 2024 12:10 pm

Hi,
Please find requested info in attached file.

Regards,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Mon Jan 29, 2024 10:24 am

Hello,

Thank you for your feedback.
Based on the information you provided, I have checked and found that the Calibri font is not installed in your Linux environment. Starting from Spire.Doc for Java 12.1.0, we have enhanced font detection, which may have caused the issue you mentioned.
In Spire.Doc, when converting Word to PDF, you can specify the font file path. To resolve this issue without installing the font in the testing environment, please place the Calibri font file used in your Word document into the "Fonts" folder and use the following code for testing:
Code: Select all
// Create a new Document object
Document document = new Document();
// Load the document from the specified file, automatically detecting the file format
document.loadFromFile("hebrew.docx", FileFormat.Auto);
// Set the custom fonts folder path
document.setCustomFontsFolders("Fonts");
// Save the document to a PDF file at the specified path using the PDF format
document.saveToFile("output/result-12.1.16.pdf", FileFormat.PDF);

This way, you won't need to install the font in the testing environment.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Feb 01, 2024 12:09 am

Hi,
Thanks for quick answer.
We are not able to get proper pdf with Hebrew using next code:
Code: Select all
    public Result convert(Http.Request request) throws Exception {
        Http.MultipartFormData<Files.TemporaryFile> body = request.body().asMultipartFormData();
        Http.MultipartFormData.FilePart<Files.TemporaryFile> file = body.getFile("file");
        Document document = new Document();
        document.loadFromFile(file.getRef().path().toString());
        try {
            String path = "/usr/local/dealhub/conf/resources/fonts/";
            if (new File(path).isDirectory()) {
                log.info("Adding {} to spire.doc fonts folder", path);
                document.setCustomFontsFolders(path);
                log.info("Added {} to spire.doc fonts folder", path);
            }
        } catch (Exception ex) {
            log.error("Cannot setCustomFontsFolders", ex);
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        document.saveToStream(out, FileFormat.PDF);
        return ok(new ByteArrayInputStream(out.toByteArray()))
                .withHeader(Http.HeaderNames.CONTENT_TYPE, MimeTypesExtended.X_DOWNLOAD)
                .withHeader(Http.HeaderNames.CONTENT_DISPOSITION, "attachment; filename=\"test.pdf\"");
    }

Untitled.png

In our logs we see message about success setting of custom fonts folders

Please help to resolve this issue.


Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Thu Feb 01, 2024 2:08 am

Hello,

Thank you for your feedback.
I see that you are using the custom font file with the font "Liberation Sans". I have tested this font with the latest version of Spire.Doc and found that it does not properly support Hebrew characters, resulting in them appearing as garbled text. I have logged the issue into our bug tracking system with the ticket number SPIREDOC-10280. 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: 1651
Joined: Wed Apr 07, 2021 2:50 am

Wed Feb 07, 2024 2:29 pm

Hi,
In addition we've installed Calibri fonts to system, but still getting same results.
Code: Select all
bash-5.2# fc-list | grep calibri
/usr/share/fonts/fonts-master/calibril.ttf: Calibri,Calibri Light:style=Light,Regular
/usr/share/fonts/fonts-master/calibrib.ttf: Calibri:style=Bold
/usr/share/fonts/fonts-master/calibrii.ttf: Calibri:style=Italic
/usr/share/fonts/fonts-master/calibrili.ttf: Calibri,Calibri Light,Calibri Light Italic:style=Light Italic,Italic
/usr/share/fonts/fonts-master/calibri.ttf: Calibri:style=Regular
/usr/share/fonts/fonts-master/calibriz.ttf: Calibri:style=Bold Italic


Regards,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Thu Feb 08, 2024 8:41 am

Hello,

Thank you for your feedback.
I tested the Word document you provided earlier using Spire.Doc for Java Version:12.1.16 in a linux environment, but it still did not reproduce your problem. The fonts are still using Calibri. is this the version you tested with? If not, please upgrade to this version first. I am attaching my test code and result file for your reference.
Also, are you testing in a docker container?

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Feb 13, 2024 2:39 pm

Hi,
We've used provided code (SpireDoc for Java 12.1.16):
Code: Select all
        Document document = new Document();
        document.loadFromFile(file.getRef().path().toString(), FileFormat.Auto);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        document.saveToStream(out, FileFormat.PDF);

and getting error:
Code: Select all
Caused by: java.lang.IllegalArgumentException: Cannot detect current file type
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.loadFromFile(Unknown Source)
   at controllers.test.SpireDocConversion.convert(SpireDocConversion.java:28)


Without FileFormat.Auto conversion happen, but with Hebrew problem.
Calibri fonts installed as system fonts and accessible from Java.

Please help to resolve issue.

Full code, test file, env details in attached file.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Thu Feb 15, 2024 6:12 am

Hello,

Thanks for your feedback.
I'm sorry to tell you that we still haven't reproduced the problem you mentioned. Have you updated the version to the latest Spire.Doc 12.1.16(https://www.e-iceblue.com/Download/doc-for-java.html)? Since we are on Spring Festival vacation (until 2024-2-18) and lack the environment to reproduce the problem, we will further investigate your problem when we return to the office. Thank you for your understanding.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Wed Feb 21, 2024 3:09 pm

Hi,
Do we have any news regarding this issue?
Number of fixes depends on this upgrade.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Thu Feb 22, 2024 9:19 am

Hello,

Thank you for your follow-up.
Regarding the issue SPIREDOC-10280, our development team is currently debugging the code and has not yet resolved the issue. Rest assured, I have urged our developers to address this matter promptly. I will inform you immediately once there are any significant updates.
Additionally, may I inquire if you have conducted testing on the project I provided to you in your testing environment? If so, could you please share the results with me?

Sincerely,
Annika
E-iceblue support team
User avatar

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

Sat Feb 24, 2024 8:02 pm

Hi,
As I explained early we getting exception when use FileFormat.Auto with SpireDoc for Java (12.1.16).

Code: Select all
Caused by: java.lang.IllegalArgumentException: Cannot detect current file type
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.spr???�(Unknown Source)
   at com.spire.doc.Document.loadFromFile(Unknown Source)
   at controllers.test.SpireDocConversion.convert(SpireDocConversion.java:28)


We run our code in Docker.

Thanks,
Andrei Chorin

andrei.chorin
 
Posts: 48
Joined: Sun Jan 08, 2023 2:36 pm

Return to Spire.Doc