1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
using IronPdf;
using System.Text;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
var htmlToPdf = new HtmlToPdf();
htmlToPdf.PrintOptions.SetCustomPaperSizeInInches(12.5, 20);
htmlToPdf.PrintOptions.PrintHtmlBackgrounds = true;
htmlToPdf.PrintOptions.PaperOrientation =
PdfPrintOptions.PdfPaperOrientation.Portrait;
htmlToPdf.PrintOptions.Title = "My PDF Document Name";
htmlToPdf.PrintOptions.EnableJavaScript = true;
htmlToPdf.PrintOptions.RenderDelay = 50;
htmlToPdf.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
htmlToPdf.PrintOptions.DPI = 300;
htmlToPdf.PrintOptions.FitToPaperWidth = true;
htmlToPdf.PrintOptions.JpegQuality = 80;
htmlToPdf.PrintOptions.GrayScale = false;
htmlToPdf.PrintOptions.FitToPaperWidth = true;
htmlToPdf.PrintOptions.InputEncoding = Encoding.UTF8;
htmlToPdf.PrintOptions.Zoom = 100;
htmlToPdf.PrintOptions.CreatePdfFormsFromHtml = true;
htmlToPdf.PrintOptions.MarginTop = 40;
//millimenters
htmlToPdf.PrintOptions.MarginLeft = 20;
//millimenters
htmlToPdf.PrintOptions.MarginRight = 20;
//millimenters
htmlToPdf.PrintOptions.MarginBottom = 40;
//millimenters
htmlToPdf.PrintOptions.FirstPageNumber = 1;
//use 2 if a cover page will be appended
htmlToPdf.RenderHTMLFileAsPdf("my-content.html").SaveAs("my-content.pdf");
}
}
}
Here are some more detailed printing options
13. Use More Printing Options
15