PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Convert the email to HTML first, then read the content, export an HTML directory or write the PDF as needed. Here is an example:
using (CEmailResult result = CEmailConverter.ConvertToHtml("/mail.eml"))
{
if (!result.IsSuccess())
return;
// Get the HTML string
string html = result.GetHtml();
// Export an offline HTML directory: index.html, resources/ (body resources) and attachments/ (attachments)
result.ExportHtml("/mail_html/");
// Write the PDF from the same result; this can be called repeatedly
result.WritePdf("/mail.pdf");
}The HTML references the files under resources/ and attachments/ by relative paths, so the HTML string alone is not a complete offline copy. Use ExportHtml to export the complete directory, or set CEmailFlags.EMAIL_INLINE_RESOURCES to embed images and other resources as data URIs where possible.