MSG to PDF with scaling of message to fit page?

I'm taking your example msg to pdf, but I have a message that has a HTML table of texts and it's chopping it on the right, the page size is Letter. (attached)

How do i scale the content of the mhtml to fit the pdf page? thanks.

MailMessage mailMsg = MailMessage.Load("About Aspose-1.msg");

MemoryStream ms = new MemoryStream();

//Save as MHTML
mailMsg.Save(ms, Aspose.Email.Mail.SaveOptions.DefaultMhtml);

//create an instance of LoadOptions and set the LoadFormat to Mhtml
var loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Mhtml;

//create an instance of Document and load the MTHML from MemoryStream
var document = new Aspose.Words.Document(ms, loadOptions);

//create an instance of HtmlSaveOptions and set the SaveFormat to Html
var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();

//save the document to Html file
document.Save(“About Aspose.pdf”, saveOptions);

Hi Lee,


Thank you for writing to Aspose Support team.

The intermediate MHTML output generated by Aspose.Email API contains the full table. It seems that the issue may require some settings by Aspose.Words API in order to display the output fine. Our support staff member from Aspose.Word support team will assist you further in this regard. We appreciate your patience in this regard.

Hi Lee,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you load the intermediate MHTML output generated by Aspose.Email in MS Word and convert it to Pdf, you will get the same output. The table is rendered outside the page in output Pdf. This issue can be resolved using one of following solutions.

  1. Set the page orientation to landscape.
  2. Increase the page width.
  3. Use Table.AutoFit method with AutoFitToWindow behavior to resize the table and cells.
//create an instance of LoadOptions and set the LoadFormat to Mhtml
var loadOptions = new Aspose.Words.LoadOptions();
loadOptions.LoadFormat = LoadFormat.Mhtml;

var document = new Aspose.Words.Document(MyDir + "input.mhtml", loadOptions);

//Solution 1
document.FirstSection.PageSetup.Orientation = Orientation.Landscape;

//Solution 2
//foreach (Table table in document.GetChildNodes(NodeType.Table, true))
// table.AutoFit(AutoFitBehavior.AutoFitToWindow);

//Solutoin 3
//document.FirstSection.PageSetup.PageWidth = 800;
//create an instance of HtmlSaveOptions and set the SaveFormat to Html

var saveOptions = new Aspose.Words.Saving.PdfSaveOptions();

//save the document to pdf file
document.Save(MyDir + "Out.pdf", saveOptions);