Skip to content
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Overview ​

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)
  • One-step conversion: CEmailConverter.ConvertToPdf writes the PDF directly. The returned result also keeps the HTML, resources and diagnostics.
  • Two-step conversion: First get a conversion result with 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:

FormatDescription
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_EMLRFC 5322 / MIME email
CEmailFormat.EMAIL_FORMAT_MSGOutlook 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:

csharp
using ComPDF.PDFGeneration;
using ComPDF.PDFGeneration.EmailToPdf;