MSG to PDF Body conversion truncating issue

Hi,

I am trying to convert email-MSG file to PDF. In that msg file there is a screenshot which is in landscape size one is portrait.
After conversion of the email using Aspose java API pictures are not properly converted. I have attached the MSG file and also generated output PDF. Please help me on this proper conversion.
local images.zip (241.7 KB)

Regards,
Ayyappa S.

@ayyappa.reddy There is no page setup in MHTML document, it’s content is adjusted to the window where it is viewed. Aspose.Words is designed to work with MS Word document at first. When HTML/MHTML is imported, Aspose.Words uses standard page setup if page setup is not defined in the document. To work the problem around, you can use LayoutCollector and LayoutEnumerator to calculate actual bounds of content and adjust page size accordingly. For example see the following code:

Aspose.Email.MailMessage msg = Aspose.Email.MailMessage.Load(@"C:\Temp\in.msg");
msg.Save(@"C:\Temp\tmp.mhtml", Aspose.Email.SaveOptions.DefaultMhtml);

Aspose.Words.Document doc = new Aspose.Words.Document(@"C:\Temp\tmp.mhtml");

// Determine the maximum table width using LayoutEnumerator.
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);

double maxTableWidth = 0;
foreach (Section s in doc.Sections)
{
    foreach (Table t in s.Body.Tables)
    {
        enumerator.Current = collector.GetEntity(t.FirstRow.FirstCell.FirstParagraph);
        while (enumerator.Type != LayoutEntityType.Row)
            enumerator.MoveParent();

        maxTableWidth = Math.Max(maxTableWidth, enumerator.Rectangle.Width);
    }
}
// Calculate maximum image width.
double maxShapeWidth = 0;
double maxShapeHeight = 0;
foreach (Shape s in doc.GetChildNodes(NodeType.Shape, true))
{
    enumerator.Current = collector.GetEntity(s);
    maxShapeWidth = Math.Max(maxShapeWidth, enumerator.Rectangle.Width);
    maxShapeHeight = Math.Max(maxShapeHeight, enumerator.Rectangle.Height);
}

PageSetup ps = doc.FirstSection.PageSetup;
double pageWidth = ps.PageWidth - ps.LeftMargin - ps.RightMargin;
double pageHeight = ps.PageHeight - ps.TopMargin - ps.BottomMargin;

double maxContentWidth = Math.Max(maxShapeWidth, maxTableWidth);
if (pageWidth < maxContentWidth)
    ps.PageWidth = maxContentWidth + ps.LeftMargin + ps.RightMargin;
if (pageHeight < maxShapeHeight)
    ps.PageHeight = maxShapeHeight + ps.TopMargin + ps.BottomMargin;

// Update page layout is required since LayoutCollector and LayoutEnumerator were used.
doc.UpdatePageLayout();
doc.Save(@"C:\Temp\out.pdf");