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