We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

p.MsoNormal not being applied to pdf conversion

I have an *eml file which I am converting to pdf.

// load the EML file using Aspose.Email for .NET
MailMessage msg = MailMessage.Load(@"C:\testEmailDownload\monday.eml", MessageFormat.Eml);
// convert Eml to MHTML and save to stream
MemoryStream msgStream = new MemoryStream();
msg.Save(msgStream, MailMessageSaveType.MHtmlFromat);
msgStream.WriteTo(new FileStream(@"C:\testEmailDownload\monday.mhtml", FileMode.Create));

msgStream.Position = 0;
Document document = new Document(msgStream);
FontSettings.SetFontsFolder(@"C:\Windows\Fonts", false);
document.Save(@"C:\testEmailDownload\monday.pdf",SaveFormat.Pdf);

When I open the mhtml file the layout is ok. when I open the pdf there is extra lines being introduced. When i use fiddler to look at the mhtml file I can see that there are empty paragraphs that have p.MsoNOrmal css being applied to them. I think that this style is not being applied when the pdf conversion is happening.

I wasnt sure if it was the mso styles being ignored or inheritted css not working ???

any ideas ???




Hi Derek,


Thanks for your inquiry. This issue is happening as some of these empty MHTML paragraphs, upon loading in Aspose.Words, are having font size of 12 points. The problem seems to be resolved if somehow you set the font size value to zero and clear the formatting e.g:

LoadOptions options = new LoadOptions();<o:p></o:p>

options.LoadFormat = LoadFormat.Mhtml;

Document doc = new Document(@"C:\test\monday.mhtml", options);

NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph para in paras)

{

if (para.Runs[0] != null)

{

if (para.Runs[0].Text.Equals(ControlChar.NonBreakingSpace))

{

para.ParagraphFormat.ClearFormatting();

para.Runs[0].Font.Size = 0;

}

}

}

doc.Save(@"C:\test\out.pdf");


I hope, this will help.

Best Regards,

Thank you Awais.hafeez !!

That did the trick perfectly. I do wonder why the mso style that does this is not being applied ?

The next issue I can see is that the text "Any views and commentary in this communication are short-term views of "...

In the header is very much out of focus ?

what can I do about this ?

I have attached the updated files

Hello

Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Best regards,