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.

Thu Jan 25, 2024 4:14 pm

1. Sample Doc input file and PDF output file attached.
2. Code Snippet:
Code: Select all
         public static String convertDocToPdf(MultipartFile file) throws IOException {

      // Set license key
      // com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);

      com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);

      File tempDocFile = File.createTempFile("tempDoc", "." + "doc");
      try (FileOutputStream outputStream = new FileOutputStream(tempDocFile)) {
         IOUtils.copy(file.getInputStream(), outputStream);
      }

      File tempFile = File.createTempFile(file.getName(), "." + "pdf");

      Document document = new Document();
      document.loadFromFile(tempDocFile.getAbsolutePath(), FileFormat.Doc);

      ToPdfParameterList ppl = new ToPdfParameterList();
      ppl.isEmbeddedAllFonts(true);
      ppl.setDisableLink(true);
      document.setJPEGQuality(40);
      document.saveToFile(tempFile.getAbsolutePath(), ppl);

      return addPageNumberToPDF(tempFile.getAbsolutePath());

   }

3. Spire Office version:
Manifest-Version: 1.0
Extension-Name: spire.office
Implementation-Title: spire.office for java
Implementation-Version: 8.12.0
Implementation-Vendor: E-iceblue Co., Ltd.
Implementation-Vendor-Id: com.spire
Implementation-URL: https://www.e-iceblue.com

4. Application Type: Spingboot JDK 1.8

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Fri Jan 26, 2024 3:14 am

Hello,

Thank you for your inquiry.
I have tested the Word document you provided using Spire.Office for Java Version: 9.1.4, but I was unable to reproduce the issue you mentioned. I noticed that you are not using the latest version of Spire.Office, so please upgrade to this version for testing. Your license is valid for this version, and there have been some changes in how the license is used. Please refer to the code below.
Please note that your license is valid for this version, as there have been changes in the licensing usage for this specific version. Please refer to the code snippet below for further guidance:
Code: Select all
com.spire.doc.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
com.spire.doc.license.LicenseProvider.loadLicense();
com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
com.spire.license.LicenseProvider.loadLicense();

Additionally, I noticed that your Word document uses the "Open Sans" font, which is not present in the PDF file you provided. Please install this font and test with the latest version.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Mon Jan 29, 2024 5:17 pm

Hello,

When I'm using spire office 9.1.4 version following imports not found.

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.ToPdfParameterList;
import com.spire.doc.documents.HorizontalAlignment;
import com.spire.doc.documents.PageOrientation;
import com.spire.doc.documents.PageSize;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.formatting.ParagraphFormat

Thanks and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Tue Jan 30, 2024 1:44 am

Hello,

Thank you for providing your feedback.
Based on your description, I believe you manually imported the Spire.Office JAR file. Please note that starting from Spire Office 9.1.4, Spire.Doc is independent of Spire.Office. If you manually import the Spire.Office JAR file into your project, you also need to import the latest version of the Spire.Doc JAR file.
However, if you are using Maven to import Spire.Office, Maven will automatically import Spire.Doc for you.
If you have any further questions or require assistance with the integration, please let me know.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Jan 31, 2024 6:17 pm

Hello,

I'm still getting blocks in place of hindi characters.

Code: Select all
public static String convertDocToPdf(MultipartFile file) throws IOException {

      // Set license key com.spire.license.LicenseProvider.setLicenseKey(LICENSE_KEY);


      com.spire.doc.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
      com.spire.doc.license.LicenseProvider.loadLicense();

      File tempDocFile = File.createTempFile("tempDoc", "." + "doc");
      try (FileOutputStream outputStream = new FileOutputStream(tempDocFile)) {
         IOUtils.copy(file.getInputStream(), outputStream);
      }

      File tempFile = File.createTempFile(file.getName(), "." + "pdf");

      Document document = new Document();
      document.loadFromFile(tempDocFile.getAbsolutePath(), FileFormat.Doc);

      ToPdfParameterList ppl = new ToPdfParameterList();
      ppl.isEmbeddedAllFonts(true);
      ppl.setDisableLink(true);
      document.setJPEGQuality(40);
      document.saveToFile(tempFile.getAbsolutePath(), ppl);

      return addPageNumberToPDF(tempFile.getAbsolutePath());

   }


PFA.

Thanks and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Thu Feb 01, 2024 2:42 am

Hello,

Thank you for your feedback.
I have checked the PDF file you provided and found that the "Open Sans" font has not been embedded, leading to the display of garbled text. Please refer to the following code to load the custom font to solve this issue.
Code: Select all
...
//The "Fonts" folder contains the "Open Sans.ttf" file
Document.setGlobalCustomFontsFolders("Fonts");
Document document = new Document();
...

Sincerely,
Annika
E-iceblue support team
User avatar

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

Fri Feb 02, 2024 5:44 pm

Hello,

Im using following versions

Code: Select all
<dependency>
          <groupId>e-iceblue</groupId>
          <artifactId>spire.office</artifactId>
          <version>9.1.10</version>
          <scope>system</scope>
          <systemPath>${project.basedir}/src/main/resources/spire.office-9.1.10.jar</systemPath>
          <classifier>jar-with-dependencies</classifier>
      </dependency>
      
      <dependency>
         <groupId>e-iceblue</groupId>
         <artifactId>spire.doc</artifactId>
         <version>12.1.16</version>
         <scope>system</scope>
          <systemPath>${project.basedir}/src/main/resources/spire.doc-12.1.16.jar</systemPath>
          <classifier>jar-with-dependencies</classifier>
      </dependency>


Still getting blocks in text and also Evaluation Warning : The document was created with Spire.PDF for Java. warning on PDF.

Code: Select all
public static String convertDocToPdf(MultipartFile file) throws IOException {

      com.spire.doc.license.LicenseProvider.setLicenseKey(LICENSE_KEY);
      com.spire.doc.license.LicenseProvider.loadLicense();

      File tempDocFile = File.createTempFile("tempDoc", "." + "doc");
      try (FileOutputStream outputStream = new FileOutputStream(tempDocFile)) {
         IOUtils.copy(file.getInputStream(), outputStream);
      }

      File tempFile = File.createTempFile(file.getName(), "." + "pdf");

      Document.setGlobalCustomFontsFolders("Fonts");

      Document document = new Document();
      document.loadFromFile(tempDocFile.getAbsolutePath(), FileFormat.Doc);


      ToPdfParameterList ppl = new ToPdfParameterList();
      ppl.isEmbeddedAllFonts(true);
      ppl.setDisableLink(true);
      document.setJPEGQuality(40);
      document.saveToFile(tempFile.getAbsolutePath(), ppl);

      return addPageNumberToPDF(tempFile.getAbsolutePath());

   }


Thanks and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Fri Feb 02, 2024 5:45 pm

PFA.

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Sun Feb 04, 2024 8:09 am

Hello,

Thank you for your feedback.

I have retested the Word document you mentioned, but I was unable to reproduce the issue you encountered. I have attached my testing project, which includes the resulting file "result.pdf". Please download and test it accordingly. Please note that the testing code is located in the "src/test" directory, not in "src/main".

If the issue persists after testing, please provide your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese), so that we can further investigate and assist you.

Thank you once again for your cooperation.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Fri Feb 16, 2024 5:51 pm

Hello,

I have installed fonts but when I'm trying to start application i'm getting below error.

Caused by: java.lang.NoClassDefFoundError: com/spire/pdf/graphics/PdfFontBase

PFA for log file.

Environment info as below:

OS Name Microsoft Windows Server 2019 Standard
Version 10.0.17763 Build 17763
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
Processor Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz, 2594 Mhz, 8 Core(s), 16 Logical Processor(s)
BIOS Version/Date EFI Development Kit II / OVMF 1.5.1, 16-Jun-21


Thanks and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Sun Feb 18, 2024 6:05 am

Hello,

Thank you for your feedback.
Based on the information you provided, I tested the project previously provided to you in a Windows Server 2019 environment, but there were no issues either. May I ask if you tested the project I provided to you earlier? What was the result?
Also, the reported error you mentioned I guess it should be caused by the conflicting jar package reference of Spire.Pdf. Please check if you have only the latest versions of our Spire.Office and Spire.Doc installed in your project.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Feb 20, 2024 10:41 am

Hello,

I tried your project in my machine but still getting dependency errors.
I will share more details soon.

Thank and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Wed Feb 21, 2024 8:29 am

Hello,

Thanks for your feedback.
We regret to hear that there are still issues when directly running the program I provided. We look forward to more details from you so that we can further pinpoint the cause of the problem.
Meanwhile, please also inform us of your system region settings, such as (e.g., China, Chinese).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Wed Feb 21, 2024 5:13 pm

Hello,

I'm providing whole project in attachment. Also the postman request's export.
When I'm running your provided project in my local machine all language are showing well in converted PDF, But in my project module its not.

I'm using {{host}}/html-to-pdf-json API from provided postman export.

I'm attaching sample output files also.

Can you please help to find root cause of why some languages not getting correctly shown in generated PDF using my project module?

Also one more issue is images are getting cut/cropped in generated PDF.

Thanks in advance.

Thank and regards,
Umesh Asodekar

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Wed Feb 21, 2024 5:15 pm

Hello,

How to upload file more than 200 MB?

Thanks and regards,
Umesh

Dasgupta
 
Posts: 54
Joined: Fri Mar 11, 2022 9:14 am

Return to Spire.Doc

cron