We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text is Moved to Next Line after DOCX to PDF Conversion using Java

Hi Team,
We are using Aspose.Words jar for the conversion of Word to PDF but there is alignment mismatch between the two.

Original Word
image.png (1.2 KB)

PDFConverted
image.png (2.8 KB)

@ShwetaEY

Please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you more information on it.

Aspose Issues.zip (221.3 KB)

Uploaded the issues documents

@ShwetaEY

We have tested the scenario and managed to reproduce the same issue at our side for document 'Resumption deadline reminder_00000_v2.docx'. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22187.

We have not found the shared issue with your second document (Quarterly ann't reminder (1st)_v1.docx). However, we have noticed that the image size is changed in output PDF. We have logged this issue as WORDSNET-22188.

You will be notified via this forum thread once these issues are resolved. We apologize for your inconvenience.

@ShwetaEY

We have closed WORDSNET-22187 issue with ‘Not a Bug’ resolution. Please enable open type feature as shown below to get the desired output.

Document doc = new Document(MyDir + "input.docx");

// When text shaper factory is set, layout starts to use OpenType features.
// An Instance property returns static BasicTextShaperCache object wrapping HarfBuzzTextShaperFactory
doc.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());

// Render the document to PDF format
doc.save(MyDir + "OpenType.Document.pdf");

For more detail, please read the following article.

@ShwetaEY

We have also closed the issue WORDSNET-22188 as ‘Not a Bug’. Please note that Aspose.Words mimics the behavior of MS Word 2019. If you convert your document to PDF using MS Word 2019, you will get the same output.

We have attached the output PDF files generated by Aspose.Words and MS Word 2019 with this post for your kind reference.
ms word 2019.pdf (109.1 KB)
aw output.pdf (78.4 KB)

Hi Tahir,
If you see the PDF that you have attached getting converted from MS Word 2019 is absolutely correct , if you observe the Total no of Pages tag . But if you see it in my Aspose attachment it is incorrect in PDF.

@ShwetaEY

Please try the latest version of Aspose.Words for Java 21.4. Please check the attached PDF files generated by Aspose.Words and MS Word 2019. Both documents are same.

Hi Tahir,

Is the jar version you are talking about. Request you help me how to get the latest version of the jar you are referring here

@ShwetaEY

Please download the Jar file as shown in attached image.

https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-words/21.4/aspose-words-21.4-jdk17.jar

Aspose.Words.Jar.png (108.1 KB)

You may also download the Jar file of Aspose.Words from here:

Hi Tahir,
As instructed by you we have upgraded the jar to the latest version but still some alignment issues are present and the word and PDFs are not exact replicas of each other.
Let us know the fix .
The Tel and Total no of pages tag for word is properly aligned
image.png (4.7 KB)

But in PDF there is a slight difference
image.png (7.1 KB)

@ShwetaEY

Please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you information on it.

Hi Tahir,
For another issue where we were suppose to enable the open type feature the below error is coming in the Java code.
image.png (106.1 KB)

Have removed some code snippets as it had paths from our server

@ShwetaEY

Aspose.Words.Shaping.Harfbuzz package provides support for OpenType features in Aspose.Words using the HarfBuzz text shaping engine. Please download it from following link and include it into your Java application.

https://repository.aspose.com/repo/com/aspose/aspose-words/21.5/aspose-words-21.5-shaping-harfbuzz-plugin.jar

Hi Tahir,

Still, we are facing some issues in the conversion. We tried converting a WORD document with a simple table into a PDF. In one of the cells in the table, we have an empty line at the end. This empty line is not coming in the converted PDF. I have uploaded the Word and PDF documents for your reference.

Aspose_WORD_PDF.zip (74.1 KB)

@ShwetaEY

We have logged this problem in our issue tracking system as WORDSNET-22266. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@ShwetaEY

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-22266) as ‘Not a Bug’.

The behavior is related to “hideMark” element in table cell properties. The element specifies that an empty paragraph in the end of a table cell should not be taken into account when computing the cell height. MS Word 2019 and Aspose.Words behavior appear to match the specification. Please check the output PDF generated by MS Word 2019. msword 2019.pdf (7.8 KB)

Screenshot.PNG.jpg (85.1 KB)

Hi Tahir,

We are still facing issues with spacing. Please find the screenshot attached for more details.

You can see in the comments column of the table the first row is having one empty line above and 2 empty lines below. But in the converted PDF 1 line is coming above and only one empty line is coming below. [If pipe is coming its converting properly, but not for the circle character]

@ShwetaEY

Please check the last empty paragraphs of table’s cells. You marked them in the image. These are not rendered in output PDF. However, the empty paragraph are rendered in output PDF.

Hi Tahir,

While testing we found few spacing differences between the PDF converted by word Export function and PDF converted with Aspose code.

Word document - Spacing_Issue.docx
Screenshots are added for documents converted with Aspose code and normal word PDF conversion function.

Please check the point (iv) in the PDF_Converted_by_Aspose_Code_SS.PNG file. The dot at the end of the point is coming in the new line. But in the original word document or the PDF converted using Export function in Word its still in the above line.

Spacing_Issue.docx (33.8 KB)
PDF_Converted_by_Aspose_Code_SS.PNG (44.1 KB)
PDF_Converted_by_Word_Export_Function_SS.PNG (43.2 KB)

Please help us with this issue.