Generated PDF has paragraphs in different pages compared to DOCX when using footnotes and paragraph pagination option "Keep with next" and "Keep together "

Hi!

Software (incl. versions) where issue can be reproduced:
We’re using NUGET package “Aspose.Words” version 23.8.0 for converting from docx to pdf where we have discovered this issue. The problem can also be reproduced by using https://products.aspose.app/pdf/conversion/word-to-pdf to convert from DOCX to PDF files.

Problem examples
Provided a zip of example DOCX files (Test1.docx, Test2.docx, Test3.docx) which after using the word to PDF Aspose online convert tool to convert them to corresponding PDFs (Test1Result.pdf, Test2Result.pdf, Test3Result.pdf) have paragraphs moved to different pages compared to the original DOCX files.
AsposeProblemExamples.zip (156,0 KB)

Here are the steps that seem to reproduce the following problem where the resulting PDF has some paragraphs moved:

  1. Must have at least two paragraphs which occupy almost the entire page. Both of these paragraphs must have the paragraph pagination options “Keep with next” and “Keep Line together” checked.
  2. The paragraphs must have footnotes.
  3. Then after trying to convert such DOCX to PDF using the online Aspose Word to PDF convert tool and mentioned NUGET package, the paragraphs will have moved to a different pages in the PDF.

Thanks in advance!

1 Like

@troubledog I cannot reproduce the problem on my side using the latest 23.11 version of Aspose.Words and the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.pdf");

Test1Result_23.11.pdf (43.1 KB)
Test2Result_23.11.pdf (45.7 KB)
Test3Result_23.11.pdf (43.8 KB)

As I can see in your document DejaVuSans font is used instead of Calibri.

The problem on your side might occur because the ‘Calibri’ font used in your input document is not available on the machine where document is processed. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

You’re right. The problem was related to font substitution in the resulting PDF.

Thanks for the help!

2 Likes