The question is published on by Tutorial Guruji team.
I want to generate a PDF document from a “raw” email. This email could containt html or just text. I don’t care for attachments.
The resulting pdf should contain the proper formatting (from css and html) and also embedded images.
My first idea was to render the email using an email client like thunderbird and then print it to pdf. Does thunderbird offer such an API or are there java libraries available to print an email to pdf?
Answer
I put a piece of software together that converts eml files to pdf’s by parsing (and cleaning) the mime/structure, converting it to html and then use wkhtmltopdf to convert it to a pdf file.
It also handles inline images, corrupt mime headers and can use a proxy.
The code is available at github under apache V2 license.