PDF Generation Settings

C# + VB.Net: PDF Generation Settings PDF Generation Settings
using IronPdf;

IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();

Renderer.PrintOptions.SetCustomPaperSizeInInches(12.5, 20);
Renderer.PrintOptions.PrintHtmlBackgrounds = true;
Renderer.PrintOptions.PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait;
Renderer.PrintOptions.Title = "My PDF Document Name";
Renderer.PrintOptions.EnableJavaScript = true;
Renderer.PrintOptions.RenderDelay = 50; //ms
Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
Renderer.PrintOptions.DPI = 300;
Renderer.PrintOptions.FitToPaperWidth = true;
Renderer.PrintOptions.JpegQuality = 80;
Renderer.PrintOptions.GrayScale = false;
Renderer.PrintOptions.FitToPaperWidth = true;
Renderer.PrintOptions.InputEncoding = Encoding.UTF8;
Renderer.PrintOptions.Zoom = 100;
Renderer.PrintOptions.CreatePdfFormsFromHtml = true;

Renderer.PrintOptions.MarginTop = 40;  //millimeters
Renderer.PrintOptions.MarginLeft = 20;  //millimeters
Renderer.PrintOptions.MarginRight = 20;  //millimeters
Renderer.PrintOptions.MarginBottom = 40;  //millimeters

Renderer.PrintOptions.FirstPageNumber = 1; //use 2 if a coverpage  will be appended

Renderer.RenderHTMLFileAsPdf("my-content.html").SaveAs("my-content.pdf");
Imports IronPdf



Dim Renderer As New IronPdf.HtmlToPdf()

Renderer.PrintOptions.SetCustomPaperSizeInInches(12.5, 20)
Renderer.PrintOptions.PrintHtmlBackgrounds = True
Renderer.PrintOptions.PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait
Renderer.PrintOptions.Title = "My PDF Document Name"
Renderer.PrintOptions.EnableJavaScript = True
Renderer.PrintOptions.RenderDelay = 50 'ms
Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen
Renderer.PrintOptions.DPI = 300
Renderer.PrintOptions.FitToPaperWidth = True
Renderer.PrintOptions.JpegQuality = 80
Renderer.PrintOptions.GrayScale = False
Renderer.PrintOptions.FitToPaperWidth = True
Renderer.PrintOptions.InputEncoding = Encoding.UTF8
Renderer.PrintOptions.Zoom = 100
Renderer.PrintOptions.CreatePdfFormsFromHtml = True

Renderer.PrintOptions.MarginTop = 40 'millimeters
Renderer.PrintOptions.MarginLeft = 20 'millimeters
Renderer.PrintOptions.MarginRight = 20 'millimeters
Renderer.PrintOptions.MarginBottom = 40 'millimeters

Renderer.PrintOptions.FirstPageNumber = 1 'use 2 if a coverpage  will be appended

Renderer.RenderHTMLFileAsPdf("my-content.html").SaveAs("my-content.pdf")

IronPDF supports many customizations for generated PDF file formats including: Paper Sizes, Document output quality, Content Scaling, CSS 'media types' and JavaScript Support.