We have a .msg to be converted to PDF.
The body contains a sentence, in front of that sentence contains 15+ tab characters.
We are converting this msg file to pdf using below logic
Ligic#1:
Aspose.Words.Document document = null;
var message = Aspose.Email.MailMessage.Load(inputPath);
using (var msgStream = new MemoryStream())
{
message.Save(msgStream, Aspose.Email.SaveOptions.DefaultMhtml);
msgStream.Position = 0;
var options = new Aspose.Words.Loading.LoadOptions();
options.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
document = new Aspose.Words.Document(msgStream, options);
document.Save(outputPDF, new Aspose.Words.Saving.PdfSaveOptions());
}
Find the attached Original msg file content:
test-1 with tabs.zip (18.7 KB)
With above logic-1 convert to pdf:
Aspose_MsgToPdf_d20f5.pdf (56.0 KB)
Logic#2:
Aspose.Words.Document document = null;
var message = Aspose.Email.MailMessage.Load(inputPath);
using (var msgStream = new MemoryStream())
{
message.Save(msgStream, Aspose.Email.SaveOptions.DefaultMhtml);
msgStream.Position = 0;
var options = new Aspose.Words.Loading.LoadOptions();
options.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
document = new Aspose.Words.Document(msgStream, options);
foreach (Aspose.Words.Section section in document.Sections)
{
var pageSetup = section.PageSetup;
pageSetup.Orientation = Aspose.Words.Orientation.Portrait;
pageSetup.TopMargin = 20;
pageSetup.BottomMargin = 10;
pageSetup.LeftMargin = 10;
pageSetup.RightMargin = 10;
pageSetup.PageWidth = 842;
pageSetup.PageHeight = 1191;
}
document.Save(outputPDF, new Aspose.Words.Saving.PdfSaveOptions());
}
We tried below to set the potrait & width
It is extending to support few more tab characters → but missing the content after 25 tabls
With above logic-2 convert to pdf:
Convert_MSG2PDF_Logic-2.pdf (55.5 KB)
How to fit the total content of email body within the pdf width.