8
If the Html file is longer, often we can use arbitrary placeholders such as and replace them with
real data later.
[[NAME]]
1.
String.Format("<h1>Hello {0} !<h1>","World");
To template or "batch create" PDFs is a common requirement for Intranet and website developers.
Rather than templating a PDF document itself, with IronPDF we can template our HTML using existing, well
tried technologies. When the HTML template is combined with data from a query-string or database we end
up with a dynamically generated PDF document.
In the simplest instance, using the C# String.Format method is effective for basic "mail-merge"
7. Apply HTML Templating
DPI Printing output DPI. 300 is standard for most print jobs. Higher resolutions produce clearer images
and text, but also larger PDF files.
EnableJavaScript Enables JavaScript and Json to be executed before the page is rendered. Ideal for
printing from Ajax / Angular Applications. Also see RenderDelay.
FirstPageNumber First page number to be used in PDF headers and footers.
FitToPaperWidth Where possible, fits the PDF content to 1 page width.
Footer Sets the header content for every PDF page as Html or a String. Supports 'mail-merge'
GrayScale Outputs a black-and-white PDFl documents
Header Sets the footer content for every PDF page as Html or String. Supports 'mail-merge'
InputEncoding The input character encoding as a string
JpegQuality Quality of any image that must be re-sampled. 0-100
MarginBottom Paper margin in millimeters. Set to zero for border-less and commercial printing
applications
MarginLeft Paper margin in millimeters
MarginRight Paper margin in millimeters
MarginTop Paper margin in millimeters. Set to zero for border-less and commercial printing
applications
PaperOrientation The PDF paper orientation.
PaperSize Set an output paper size for PDF pages. System.Drawing.Printing.PaperKind. Use
SetCustomPaperSize(int width, int height) for custom sizes
PrintHtmlBackgrounds Prints background-colors and images from Html
RenderDelay Milliseconds delay to wait after Html is rendered before printing. This can use useful when
considering the rendering of JavaScript, Ajax or animations
Title PDF Document Name and Title meta-data. Not required
Zoom The zoom level in %. Enlarges the rendering size of Htm