Converting email to pdf - cutting off right side

I’m having difficulty in converting an email to pdf format when it has embedded images. That is, when an email has embedded images and their sizes differ, right side of the larger image is being cut off.
Is there any way to save the email as pdf without cutting off right side?
I’m using the below code:
mailMessage = MailMessage.Load(emailMSG, msgLoadOptions);
string sender = mailMessage.From.User ?? “”;
string fileName = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}_" + sender, mailMessage.Date);

if (!Directory.Exists(outputDir))
Directory.CreateDirectory(outputDir);
var wordLoadOptions = new Aspose.Words.LoadOptions()
{
LoadFormat = Aspose.Words.LoadFormat.Mhtml
};
mhtSaveOptions.SkipInlineImages = false;
using (var mhtStream = new MemoryStream())
{
mailMessage.Save(mhtStream, mhtSaveOptions);
Aspose.Words.Document doc = new Aspose.Words.Document(mhtStream, wordLoadOptions);
doc.Save(outputDir + “\” + fileName + “.pdf”, Aspose.Words.SaveFormat.Pdf);
}

@Senth

Can you please save the MSG to MHTML file on disc and share if the outputs are identical. If there is no issue in MHTML but observed in PDF then it is Aspose.Words issue. Otherwise it is Aspose.Email issue. Please share the source MSG, MHTML and PDF files reproducing the issue with us.

To Aspose.zip (4.6 MB)
@mudassir.fayyaz - Thanks for your prompt reply. I 've uploaded MSG, MHTML and PDF output file. Let me know if you need any further details.

@Senth

I have created an issue with ID EMAILNET-40042 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@mudassir.fayyaz - I was just wondering if you have resolved the email to pdf issue?

@Senth

We have internally verified the issue w.r.t Aspose.Email API and it doesn’t seems to be an issue with Aspose.Email API while rendering to MHTML. We need to investigate further w.r.t Aspose.Words for exported PDF and will share the feedback with you as soon as possible.

@Senth

The images are rendered outside the page because images’ size is greater than page width. You need to reduce the image size or increase the page width to fit the image on page. Following code example shows how to reduce the image size according to page width.

Document doc = new Document(MyDir + "Testing ... please ignore....mht");
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
    ResizebigImage(shape);
}
                
doc.Save(MyDir + "21.2.pdf"); 

public static void ResizebigImage(Shape image)
{
    // Return if this shape is not an image.
    if (!image.HasImage)
        return;

    // Calculate the free space based on an inline or floating image. If inline we must take the page margins into account.
    PageSetup ps = image.ParentParagraph.ParentSection.PageSetup;
    double freePageWidth = image.IsInline ? ps.PageWidth - ps.LeftMargin - ps.RightMargin : ps.PageWidth;
    double freePageHeight = image.IsInline ? ps.PageHeight - ps.TopMargin - ps.BottomMargin : ps.PageHeight;


    ImageSize size = image.ImageData.ImageSize;
    Boolean exceedsMaxPageSize = size.WidthPoints > freePageWidth || size.HeightPoints > freePageHeight
        || image.Width > freePageWidth || image.Height > freePageHeight;

    if (exceedsMaxPageSize)
    {
        // Set the new size.
        image.AspectRatioLocked = true;
        image.Width = ps.PageWidth - ps.LeftMargin - ps.RightMargin;
    }
}

Thanks @tahir.manzoor and @mudassir.fayyaz for your help.