Shapes are Overlapped | DOCX to PDF conversion using .NET

Hello,

The PDF export of DOCX files is broken is several places: images on page in horizontal format and column of several nested elements. Three files are included to demonstrate it: the base docx file (inside a zip), a pdf exported with Microsoft Word and the one with Aspose.

Could you take a look? Thank you.

report_source.zip (4.8 MB)
report_microsoft-word.pdf (5.8 MB)
report_aspose.pdf (5.3 MB)

@tmunoz

Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you are converting documents to PDF. Please refer to the following articles:

Using TrueType Fonts
Manipulating and Substitution TrueType Fonts

Moreover, please execute the following code example to get the missing fonts notifications.

Document doc = new Document(MyDir + "report_source.docx");
doc.WarningCallback = new HandleDocumentWarnings();
doc.Save(MyDir + "21.2.pdf");

public class HandleDocumentWarnings : IWarningCallback
{
    /// <summary>
    /// Our callback only needs to implement the "Warning" method. This method is called whenever there is a
    /// potential issue during document procssing. The callback can be set to listen for warnings generated during document
    /// load and/or document save.
    /// </summary>
    public void Warning(WarningInfo info)
    {
        // We are only interested in fonts being substituted.
        if (info.WarningType == WarningType.FontSubstitution)
        {
            Console.WriteLine(info.WarningType + " :: " + info.Description.ToString());
        }
    }
}

Thank you for your response.

I’ve now executed the code example in a setup where all fonts were available, so there were no warnings. However, there’s still the same formatting issue I had in the files I included in my first message.

There are these warnings during conversion:

MinorFormattingLoss :: Table width exceed maximum allowed, table was resized.
MinorFormattingLoss :: Table column widths may need to be calculated. Rendered column widths could differ.
    At Table 1, Section 1
MinorFormattingLoss :: Table column widths may need to be calculated. Rendered column widths could differ.
    At Table 1, Section 2
[...]

Are there related to the issues I’m dealing with?

@tmunoz

Are you still facing issue after installing the fonts? Please ZIP and attach the problematic PDF if you still face any issue. We will investigate this issue further and provide you information on it.

Yes, I am still facing the issue. I attached a zip file containing:

  • report_source.docx : the base document to export to pdf
  • report_aspose.pdf : the document exported with Aspose, with issues (from the prod server without the correct font)
  • report-aspose-fontfix : the partial document exported with a the evaluation copy of Aspose, with the correct fonts, but still with issues (evaluation copy for quick testing)
    pdf-report.zip (9.7 MB)

Thank you,

@tmunoz

We have tested the scenario using the latest version of Aspose.Words for .NET 21.2 and have not found the shared issue. Please use the latest version of Aspose.Words for .NET 21.2 and apply license before importing document. We have attached the output PDF with this post for your kind reference. 21.2.pdf (5.4 MB)

Thank you for your time. But I still see issues with the 21.2.pdf file: page 5 is wrongly formatted compared to the same page in the docx document: the 5 columns grid is squashed in the center.

Thank you,

@tmunoz

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21913. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hello, I would like to know if there is any progress on this issue?

Thanks you,

@tmunoz

Your issue is related to missing feature WORDSNET-832 (Make table layout as close to Word as possible). The WORDSNET-21913 has been postponed due to this missing feature.

After the fix of WORDSNET-832, we will look into your issues. We will be sure to inform you via this forum thread as soon as this feature is available. We apologize for your inconvenience.

Hello,

Thank you for these informations. In the meantime, is there some workarounds or best practices to avoid wrongly-converted table layout?

Thank you,

@tmunoz

As a workaround, please call Document.UpdateTableLayout method as shown below. Hope this helps you.

Document doc = new Document(MyDir + "report_source.docx");
doc.UpdateTableLayout();
doc.Save(MyDir + "21.5.pdf");