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.
When CConverterProperties is supplied, its page size, page margins and header/footer settings are used as they are, including explicit zero margins, and the default email margins no longer apply. A new CConverterProperties has zero margins, so set the page margins explicitly. The base URI in CConverterProperties has no effect. Here is an example:
using (CConverterProperties properties = new CConverterProperties())
{
// US Letter paper, in points
properties.SetPageSize(new CSize { Width = 612, Height = 792 });
// Page margins, in CSS px
properties.SetPageMargins(new CPageMargins { Top = 48, Right = 48, Bottom = 48, Left = 48 });
// Show page numbers in the footer
properties.SetHeaderFooterOptions(new CHeaderFooterOptions
{
DisplayHeaderFooter = true,
HeaderTemplate = "<div></div>",
FooterTemplate = "<div style='font-size:9px;text-align:center;padding-top:16px'>" +
"<span class='pageNumber'></span> / <span class='totalPages'></span></div>"
});
using (CEmailResult result = CEmailConverter.ConvertToPdf("/mail.msg", "/mail.pdf", CEmailFormat.EMAIL_FORMAT_MSG, null, properties))
{
}
}For how to use headers and footers, see Page Margins and Headers/Footers.