Retain Text Table Indentation during Word DOCX Document to PDF Conversion using C# .NET | Auto Fit Fixed Column Widths

Hello,

We have encountered the following issue when converting to PDF an docx, as the indentation is changed. I have attached the sample files ( docx and the resulting PDFs) .
Running the latest Aspose.Words for .NET 18.11.sample misformatting.zip (115.6 KB)

Usually by inspecting the warnings from the iWarningCallback interface, I can get an idea of the possible fix.
But in this case, the fix I could find is not working. Specifically, by changing the AutoFit behavior, but I couldn’t see any changes in the output file. Code Snippet:

    string filePath = @"../../in.docx";
    string filePath2 = @"../../out.pdf";
    Aspose.Words.Document document = new Aspose.Words.Document(filePath);
    foreach( Aspose.Words.Tables.Table t in document.GetChildNodes(Aspose.Words.NodeType.Table,true)) 
   {
        t.AllowAutoFit = false;
        t.AutoFit(Aspose.Words.Tables.AutoFitBehavior.FixedColumnWidths);
    }

    Aspose.Words.Saving.PdfSaveOptions pdfSaveOptions = new Aspose.Words.Saving.PdfSaveOptions();

    document.Save(filePath2, pdfSaveOptions);

Attached are the warnings I got as well.

@hssupport,

We tested the scenario and managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17795. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

@hssupport,

After further investigation, we believe this is a rounding issue. The fix is not known yet.

The document has custom default tab width of 28.35 pt and a custom tab stop at 170.1 pt (~28.35 pt * 6). Several paragraphs have 3 tabs to separate content. In this scenario second tab receives zero width in MS Word whereas Aspose.Words computes non-zero width. As a workaround, custom default tab width can be set to 19.85 pt and paragraph “ASDF SDAASD (SADASDD) teSTASDre te ”asdtgrasgsdfaa”” needs to get one more tab after (SADASDD).

Also, your code adjusts tables, but document does not have any tables. So, it might be that you wanted to use table for alignment. In this case, all tabs need to be removed and content shall flow into cells instead. It will eliminate the issue.

We will keep you posted on any further updates.