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

Free Support Forum - aspose.com

Email -> Pdf Conversion yields portions left out

Hi team,

We are using your the following code to convert MSG to PDF -
ByteArrayOutputStream result = new ByteArrayOutputStream();
try {
log.info(“Initiating Email to pdf conversion”);
MailMessage mailMsg = MailMessage.load(emailInputStream);
// converting mailMsg to HTML (aspose doesn’t support direct eml -> pdf conversion)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mailMsg.save(baos, SaveOptions.getDefaultMhtml());

        // loading HTML into Aspose.Words Document
        LoadOptions lo = new LoadOptions();
        lo.setLoadFormat(LoadFormat.MHTML);
        Document document = new Document(new ByteArrayInputStream(baos.toByteArray()), lo);

        // finally saving Document as PDF.
        document.save(result, SaveFormat.PDF);
        return result.toByteArray();


    } catch (Exception ex) {
        log.error("Exception occurred while converting Email to pdf :", ex);
        throw ex;
    } finally {
        result.close();
    }

Here’s the email file being used - RE_ CORS CDRT September Release_ Confirmation - Draft.zip (69.4 KB)

The converted pages towards the end have main content left out.
Please suggest a solution.

Regards,
Shaurya

@shaurya.chawla

We have converted the shared EML to MHTML using Aspose.Email for Java and have not found any issue with output MHTML. Please check the output. output.zip (27.9 KB)

Could you please share your problematic output PDF along with screenshots of problematic sections of output? We will investigate this issue further and provide you more information onit.

Hey,
Thanks for your reply.

The output you have provided is clearly incorrect if you compare with the email I had attached earlier.
asp.zip (197.3 KB)
screenshots showing the discrepancy.

Let me know if anything else is required.

Thanks
Shaurya

@shaurya.chawla

We opened the output MHTML in MS Word 2019. The output looks good.
MS Word 2019.png (99.1 KB)

However, the output looks incorrect in Internet Explorer. We have logged this issue in our issue tracking system as EMAILNET-40726. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@shaurya.chawla

We have closed the issue EMAILNET-40726 as ‘Not a Bug’. Aspose.Email does not change html body in any way. You can save message to HTML and see correct result.

This is known issue with different html rendering engines for IE and MS Office. If you open output MHT file in MS Word instead IE you will be able to see expected result.

We suggest you please read the following articles.