Table is truncated after MHT to PDF using Aspose.Words for .NET

Hi Team,

I have an issue in EML to pdf conversion
in case any table is found in email body, so in final pdf its truncated.
attaching zip file which include input EML file, outpdf file and sample code for your reference.

Aspose truncate issue.zip (75.2 KB)
regards
Tarun

@genpact

You have shared the portion of sample code and not complete working code to use and verify the issue. Can you please try saving EML to MHT file and see if the rendering is fine or not. If there is no issue with MHT then its an issue related to Aspose.Words. If you observe issue in MHT then its an issue related to Aspose.Email. I suggest you to please try using latest versions of Aspose.Email and Aspose.Words. In case there is still an issue then based on my suggestion, you can identify if its Aspose.Email or Aspose.Words related issue.

@mudassir.fayyaz

attaching complete code
Sample code.zip (1.1 KB)

@genpact

After working with sample code shared by you, it is observed that MHTML is rendered fine using Aspose.Email but the issue is reproduced when saving MHTML as PDF. We request for your patience and the concerned team will investigate the issue further.

SavedMHT.zip (4.5 KB)

@genpact

Please use Table.AutoFit method as shown below to get the desired output. Hope this helps you.

var word = new Aspose.Words.Document(MyDir + "Saved.MHT");
foreach (Table table in word.GetChildNodes(NodeType.Table, true))
{
    table.AutoFit(AutoFitBehavior.AutoFitToWindow);
}
word.Save(MyDir + "output.pdf");

@tahir.manzoor

Thanks, autofit code works for me.

regards
Tarun

Your above code is working fine, but can we have some better output, I mean in case a very large table it fit to page, but when user tries to zoom pdf, table will adjust again.

I am attaching pdf here, is it possible when user zoom this pdf, table autoadjust again according to its content.

tarun.srivastava@genpact.digital_27-08-2020_06-04-43 (1).pdf (118.4 KB)

regards
Tarun Srivastava

@genpact

You can change the orientation of page to landscape using PageSetup.Orientation property. Please check the following code snippet. Hope this helps you.

var word = new Aspose.Words.Document(MyDir + "Saved.MHT");
word.FirstSection.PageSetup.Orientation = Orientation.Landscape;
foreach (Table table in word.GetChildNodes(NodeType.Table, true))
{
    table.AutoFit(AutoFitBehavior.AutoFitToWindow);
}
word.Save(MyDir + "output.pdf");