Hi team,
RE Automators October Primary Release - QA Sign Off Request.zip (27.3 KB)
is the sample file. We are using the following versions -
asposeCellsVersion=22.7
asposeEmailVersion=22.5:jdk16
asposePdfVersion=22.6
asposeWordsVersion=21.10:jdk17
With the following code -
public byte[] convertEmailToPdf(ByteArrayInputStream emailInputStream) throws Exception {
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.getDefaultHtml()); // Commenting because I remember there were issues with MHTML conversions the last time.
mailMsg.save(baos, SaveOptions.getDefaultMhtml());
// loading MHTML 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();
}
}
converted-file.pdf (23.6 KB)
is the converted file.
The converted file doesn’t cover the entire table from the original email.
Please help!