Conversion to pdf speed

Hi,

We’re using several Aspose libraries to convert different file formats to pdf. Recently we’ve noticed that converting from .msg takes significantly longer than other formats. Please see the attached project - on startup, it converts a sample msg file into mhtml, docx, and xlsx to allow for an apples-to-apples comparison between converting similar file in different formats. It then converts each of the four formats(msg, mhtml, xlsx, and docx) to .pdf, displaying time elapsed for each, in a loop to account for warmup in managed code.
Converting from .msg (as per instructions in Saving an Email as PDF|Documentation, first to mhtml stream and then to pdf with Aspose.Words) consistently takes the longest among the for formats. It is closely followed by Aspose.Words loading directly from a mhtml in the preparation step, so it seems that the main difficulty is loading the mhtml generated by Aspose.Email into Aspose.Words.
Are there any ways we could change our code to speed the conversion up? Or better yet, would it be possible to add a direct conversion to pdf into Aspose.Email and avoid the in-between step with mhtml and Aspose.Words entirely?

ConvertSpeedComparison.zip (9.9 KB)

@acturisaspose

It sounds like you’re experiencing slower conversion times when processing .msg files compared to other formats. This issue is often due to the additional steps involved in converting .msg to MHTML and then to PDF, particularly the loading of the MHTML content into Aspose.Words.

To address this, I recommend the following solutions:

  1. Optimize MHTML Generation: Ensure that the MHTML generation from the .msg file is as efficient as possible. Review the settings and options used during this conversion to identify any potential optimizations.

  2. Direct Conversion Suggestion: Currently, Aspose.Email does not support direct conversion from .msg to PDF. However, you can suggest this feature to the Aspose team, as they often consider user feedback for future updates.

  3. Profile Your Code: Utilize profiling tools to identify bottlenecks in your conversion process. This will help you determine whether the delay is occurring during MHTML generation or PDF conversion.

  4. Implement Parallel Processing: If you are converting multiple files, consider implementing parallel processing to handle multiple conversions simultaneously. This can significantly reduce overall processing time.

  5. Manage Memory Efficiently: Ensure that your application is managing memory effectively. Slow performance can sometimes be attributed to memory issues, especially when dealing with large files.

Here’s a minimal code snippet to illustrate how you might structure your conversion process:

// Load the .msg file
var mailMessage = MailMessage.Load("path/to/message.msg");

// Convert to MHTML
using (var mhtmlStream = new MemoryStream())
{
    mailMessage.Save(mhtmlStream, SaveOptions.DefaultMhtml);
    mhtmlStream.Position = 0; // Reset stream position for reading

    // Load MHTML into Aspose.Words
    var document = new Document(mhtmlStream);
    
    // Save as PDF
    document.Save("output.pdf", SaveFormat.Pdf);
}

Please implement these suggestions and let me know if they improve your conversion times or if you have any further questions!