Convert Word DOCX Document to PDF & Retain Text Position on all Pages using C# .NET


When converting DOCX to PDF, I noticed the last line of text was pushed to the next page, resulting in an extra page in the PDF.

var doc = new Document(@".\test.docx");
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;

I’ve attached my test files and a screenshot for your reference. Could you please help to take a look?

image.png (51.7 KB) (271.0 KB)



After an initial test with the latest (20.5) version of Aspose.Words for .NET, we were unable to reproduce this issue on our end. Please see the output PDF document that we generated from “test.docx” on our end by using the following simple C# code:

C# Code:

Document doc = new Document("E:\\Temp\\test\\test.docx");
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;

Hi @awais.hafeez

Thanks for your updates. Indeed after I upgraded my Aspose 20.3.0 to 20.5.0. The issue does no longer happen.

Thanks for your help.


Thanks for your feedback. It is great that you were able to get the desired output when using the latest version of Aspose.Words on your end. Please let us know any time you may have any further queries in future.