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 an email file directly to a PDF file. Here is an example:
string emailPath = "/mail.eml";
string pdfPath = "/mail.pdf";
// The result must be disposed, also when the conversion fails
using (CEmailResult result = CEmailConverter.ConvertToPdf(emailPath, pdfPath))
{
if (result.IsSuccess())
{
Console.WriteLine("PDF conversion successful");
}
else
{
Console.WriteLine($"Conversion failed: {result.GetStatus()}, PDF error: {result.GetPdfError()}");
}
}Without page properties, the PDF uses A4 paper with 32 px top/bottom and 40 px left/right margins on every page.
using (FileStream emailStream = File.OpenRead("/mail.msg"))
using (FileStream pdfStream = File.Create("/mail.pdf"))
using (CEmailResult result = CEmailConverter.ConvertToPdf(emailStream, pdfStream))
{
// If the conversion fails, pdfStream may contain partial data that must be discarded
}The email stream is read from its current position to the end. Seekable streams are read in blocks by the SDK; other streams are read into memory first. You can also pass the email bytes directly: CEmailConverter.ConvertToPdf(byte[] emailData, Stream pdfStream).