Hi, I have an email (M1.eml) with a Word document (A.docx) and an email (M2.msg) attached. The attached email (M2.msg) that has two Word documents (A.docx and B.docx) attached.
M1.eml
- A.docx
- M2.msg
- A.docx (same filename but different content)
- B.docx
I want to convert everything to PDF and need the email-structure in the end. After converting with
EmailLoadOptions loadOptions = new EmailLoadOptions();
loadOptions.setConvertOwner(true);
loadOptions.setConvertOwned(true);
loadOptions.setDepth(2);
I get 5 PDF streams/files “flatten”. How can I determine which A.docx became which PDF? Apart from the sourceFileName, I don’t get any additional information about the source in SaveDocumentStreamForFileType or ConvertedDocumentStream. (i.e. no Content-ID, no length, no source stream that I could use to create a hash code, etc.)
Does anyone have an idea?
@claas.ruschmeyer
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CONVERSIONJAVA-2471
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hello @claas.ruschmeyer
Sorry for the delay in investigating your issue. You’re absolutely right—when converting .eml to .pdf page by page, the output file/stream gets overwritten. This bug is already logged under ticket ID CONVERSIONJAVA-1680, and we expect it to be resolved in version 24.12. We’ll be sure to notify you as soon as the fix is available.
In the meantime, you can use a simple workaround - create unique names for each resulting file:
//Сreate a unique file name for each page
SavePageStream getPageStream = pageNumber -> {
try {
String fileName = java.util.UUID.randomUUID().toString();
return new FileOutputStream(String.format("C:\\Output\\%s-%d.pdf", fileName , pageNumber),false);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
};
// Load the source EML file
Converter converter = new Converter("C:\\test.eml");
// Save converted PDF file
converter.convert(getPageStream, new PdfConvertOptions());
As for ConvertedDocumentStream, it’s currently not functioning properly. We’re aware of this and plan to fix it in the GroupDocs.Conversion for Java 24.12 release.
If you have any further questions, don’t hesitate to contact us.