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.
ComPDF Generation SDK can convert EML and Outlook MSG emails to HTML and PDF. The conversion has two stages:
Email (EML/MSG) ──parse──▶ Conversion result (CEmailResult) ──output──▶ PDF
│
├── GetHtml / ExportHtml: HTML and an offline HTML directory
├── Resources, attachments and diagnostics
└── WritePdf: write the PDF (can be called repeatedly)CEmailConverter.ConvertToPdf writes the PDF directly. The returned result also keeps the HTML, resources and diagnostics.CEmailConverter.ConvertToHtml, then export the HTML, read attachments or write the PDF as needed. This suits scenarios where the same email needs both an HTML preview and a PDF.Supported email formats:
| Format | Description |
|---|---|
CEmailFormat.EMAIL_FORMAT_AUTO (default) | Detected automatically: a file starting with the CFB compound document signature is parsed as MSG, anything else as EML. The file extension is not used |
CEmailFormat.EMAIL_FORMAT_EML | RFC 5322 / MIME email |
CEmailFormat.EMAIL_FORMAT_MSG | Outlook MSG email, with HTML, RTF and plain text bodies |
Writing a PDF requires an initialized license. Converting to HTML and exporting HTML do not.
The email conversion classes (CEmailConverter, CEmailResult, CEmailOptions and others) are in the ComPDF.PDFGeneration.EmailToPdf namespace, and CConverterProperties and the other page setting classes are in the ComPDF.PDFGeneration namespace. Add the following before use:
using ComPDF.PDFGeneration;
using ComPDF.PDFGeneration.EmailToPdf;