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

Free Support Forum - aspose.com

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

Hi,

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.

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

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)
test.zip (271.0 KB)

Thanks,

@ServerSide527,

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;
doc.Save("E:\\Temp\\test\\20.5-HarfBuzz.pdf");

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.

@ServerSide527,

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.