Converting word document to pdf causes a table to be moved to next page

Hi,
i want to convert a word document into a PDF document.
When converting test file “Test OK.docm” to PDF document, everything seems to be fine. The table on first page will not be moved.
When converting test file “Test FAIL.docm” to PDF document, the table on first page will be moved to second page. We did not expect this.
Main difference between both files is the text box on right side of first page of file “Test FAIL.docm”.

I have tested this szenario with latest library of Aspose.Word 25.3
Test OK.zip (134.7 KB)

Test FAIL.zip (135.1 KB)

Code for reproducing:

String path = "c:\\Test\\";
Document documentOk = new Document(path + "Test OK.docm");
documentOk.save(path + "Test OK.pdf", SaveFormat.PDF);
Document documentFail = new Document(path + "Test FAIL.docm");
documentFail.save(path + "Test FAIL.pdf", SaveFormat.PDF);

Do you have an idea to avoid this error? Thanks a lot.

Best regards
Matthias

@curmas

It seems that the issue you are experiencing with the table moving to the next page during the conversion of your Word document to PDF may be related to the layout and positioning of elements within the document, particularly the text box on the right side of the first page in “Test FAIL.docm”.

Here are a few suggestions to help you avoid this issue:

  1. Check Text Box Properties: Ensure that the text box does not have properties that could affect the layout of the table. For instance, check if the text box is set to “float” or if it has any margins that might push the table down.

  2. Adjust Table Properties: You can try adjusting the properties of the table itself. Make sure that the table is set to not allow page breaks within it. This can often be done in the Word document by selecting the table, going to the table properties, and ensuring that the “Allow row to break across pages” option is unchecked.

  3. Use PdfSaveOptions: When saving the document to PDF, you can use PdfSaveOptions to control various aspects of the conversion. For example, you might want to set options that affect how the layout is handled during conversion. Here’s a sample code snippet to illustrate how to use PdfSaveOptions:

    using Aspose.Words;
    using Aspose.Words.Saving;
    
    string path = "c:\\Test\\";
    Document documentFail = new Document(path + "Test FAIL.docm");
    
    PdfSaveOptions saveOptions = new PdfSaveOptions
    {
        // Set any specific options you need here
        // For example, you can set compliance level
        Compliance = PdfCompliance.Pdf17
    };
    
    documentFail.Save(path + "Test FAIL.pdf", saveOptions);
    
  4. Test with Different Layouts: If possible, try modifying the layout of the “Test FAIL.docm” document by moving the text box or adjusting its size to see if that resolves the issue.

  5. Update Aspose.Words: Ensure that you are using the latest version of Aspose.Words, as updates may include fixes for layout issues during conversion.

If these suggestions do not resolve the issue, consider sharing the specific properties of the text box and table, as well as any additional layout settings that might be affecting the conversion. This information could help in diagnosing the problem further.

Feel free to reach out if you have any more questions or need further assistance!

Hi support,

i think the cause of problem should be solved.

Kind regards
Matthias

@curmas I cannot reproduce the problem on my side. Here are PDF documents produced on my side
MS Word: ms.pdf (120.7 KB)
Aspose.Words: out.pdf (87.8 KB)

Most likely the problem occurs because the fonts are not available on the machine where the document is converted to PDF. If Aspose.Words cannot find the fonts used in the document the fonts are substituted. This might lead into the layout differences due to differences in fonts metrics. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/