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.

Wed Oct 02, 2024 6:39 am

As per the sample code provided in java based SPIRE.DOC api, the document in docx format containing tables also, is converted to PDF. The part of text in cells is hidden and number of pages are increased as showing in document format.

Kindly provide the API to convert the doc to pdf as image impression.


Regards
Daya Shanker
C-DOT Delhi

dayachaubey
 
Posts: 6
Joined: Wed Aug 14, 2024 4:47 pm

Wed Oct 02, 2024 8:23 am

Hello,

Thanks for your inquiry.
Kindly note that if a Word document contains complex tables, it may indeed result in differences between the converted PDF format and the original document. Even if converted it to image format, formatting issues will not be resolved. For your case, we suggest that you provide us with your input document, and we will further investigate and provide a solution. You can upload the document to the attachment here or send it to [email protected] via email. Thank you in advance.

Sincerely,
William
E-iceblue support team
User avatar

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

Tue Oct 15, 2024 3:11 pm

Please find the attached document. COnverting to PDF of single page document gives 2 page PDF document and font/style also get changed. Following are the code program written for this conversion:

doc = new Document();
doc.loadFromFile(file_path);
ToPdfParameterList parameters = new ToPdfParameterList();
parameters.setPdfConformanceLevel(PdfConformanceLevel.Pdf_A_3_A);
parameters.setMimicWPSLayout(true);
doc.setKeepSameFormat(true);
doc.clearMacros();
doc.saveToFile(outputfile, parameters);

Please help to provide appropriate JAVA API for the conversion of doc/docx to PDF

Regards
Daya Shanker

William.Zhang wrote:Hello,

Thanks for your inquiry.
Kindly note that if a Word document contains complex tables, it may indeed result in differences between the converted PDF format and the original document. Even if converted it to image format, formatting issues will not be resolved. For your case, we suggest that you provide us with your input document, and we will further investigate and provide a solution. You can upload the document to the attachment here or send it to [email protected] via email. Thank you in advance.

Sincerely,
William
E-iceblue support team

dayachaubey
 
Posts: 6
Joined: Wed Aug 14, 2024 4:47 pm

Wed Oct 16, 2024 8:46 am

Hello,

Thanks for your feedback.
I converted your file to pdf using our latest Spire.Doc for Java Version:12.9.4, but did not encounter the issue you mentioned. Are you using this version? Here I hava uploaded my results and test code for your reference. To help us investigate further, please write back to tell us your test environment (eg: Windows 10), and provide us with the generated pdf file. Thanks in advance.
Code: Select all
Document document = new Document();
document.loadFromFile("KRA_RA_April 24 to sep24.doc");
document.saveToFile("KRA_RA_April 24 to sep24.pdf");


Sincerely,
William
E-iceblue support team
User avatar

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

Wed Oct 16, 2024 11:25 am

Thanks for your response,

The format of PDF shared after converting is correct. But this is to inform you that same piece of code i have used to convert the same doc/docx to PDF, formatting is not proper and expanding to two pages in PDF. I am using Ubuntu 20.04 OS and java version 1.17 for running the application.

Kindly suggest for this environment for doc to PDF conversion.


Regards
Daya Shanker

William.Zhang wrote:Hello,

Thanks for your feedback.
I converted your file to pdf using our latest Spire.Doc for Java Version:12.9.4, but did not encounter the issue you mentioned. Are you using this version? Here I hava uploaded my results and test code for your reference. To help us investigate further, please write back to tell us your test environment (eg: Windows 10), and provide us with the generated pdf file. Thanks in advance.
Code: Select all
Document document = new Document();
document.loadFromFile("KRA_RA_April 24 to sep24.doc");
document.saveToFile("KRA_RA_April 24 to sep24.pdf");


Sincerely,
William
E-iceblue support team

dayachaubey
 
Posts: 6
Joined: Wed Aug 14, 2024 4:47 pm

Thu Oct 17, 2024 2:12 am

Hello,

Thanks for your inquiry.
We speculate that the reason for your issue is that you don't have the "Arial" font installed on your Ubuntu. When converting documents, in order to ensure the conversion effect, our program will read the font files used in the word document from the system. If these font files are not available on the system, approximate fonts will be loaded to convert the file, which may cause the layout of the document to change after conversion. So we recommend that you install the "Arial" font and retest.

Sincerely,
William
E-iceblue support team
User avatar

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

Thu Oct 17, 2024 6:44 am

Please suggest the way to include fonts to the application using Spire.Office for APIs com.spire.xls.Workbook, com.spire.xls.Document, com.spire.xls.PdfDocument, com.spire.xls.Presentation.

The fonts are installed at Ubuntu and residents at location /usr/share/fonts/truetype

Kindly reply

Regards
Daya Shanker

William.Zhang wrote:Hello,

Thanks for your inquiry.
We speculate that the reason for your issue is that you don't have the "Arial" font installed on your Ubuntu. When converting documents, in order to ensure the conversion effect, our program will read the font files used in the word document from the system. If these font files are not available on the system, approximate fonts will be loaded to convert the file, which may cause the layout of the document to change after conversion. So we recommend that you install the "Arial" font and retest.

Sincerely,
William
E-iceblue support team

dayachaubey
 
Posts: 6
Joined: Wed Aug 14, 2024 4:47 pm

Thu Oct 17, 2024 7:58 am

Hello,

Thanks for your feedback.
Does the issue still exist after installing the font? The following is the code for specifying font paths for each product:
Spire.Doc:
Code: Select all
Document document = new Document();
document.setCustomFontsFolders("fontPath");

Spire.Xls:
Code: Select all
Workbook workbook = new Workbook();
workbook.setCustomFontFileDirectory(new String[]{"fontPath"});

Spire.Presentation:
Code: Select all
Presentation presentation = new Presentation();
Presentation.setCustomFontsFolder("fontPath");

Spire.PDF:
Code: Select all
 PdfDocument doc = new PdfDocument();
 PdfDocument.setCustomFontsFolders("fontPath");

Sincerely,
William
E-iceblue support team
User avatar

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

Return to Spire.Doc