IronSoftware
  • Products
    Read, edit, and sign PDFs Image to text in 127 languages Read and write QR & Barcodes No Office Interop required Extract structured data from websites 5 for the Price of 2 All 5 .NET product licenses from $798 Save 60% with Iron Suite
  • About Us
  • Home
  • Licensing
  • Get Started
  • Features
  • Code Examples
  • Tutorials
  • FAQ
  • API Reference
  • Support
IronPDF Library for C#
  • Home
  • Licensing
  • Docs
    • Get Started
    • Features
    • Code Examples
    • Tutorials
    • FAQ
    • API Reference
    • Support
  • Install with NuGet
Iron Pdf
IronPDF
Code Examples
  1. IronPDF
  2. Code Examples
  3. PDF Generation Settings
nuget   download  help
Iron Pdf
HTML to PDF HTML Files to PDF URL to a PDF ASPX Pages to PDF ASPX To PDF Settings Images To PDF TIFF to PDF Rasterize a PDF to Images PDF Generation Settings Async PDF Generation Set Temp PDF File Path
Headers & Footers HTML Headers & Footers PDF Forms Responsive HTML to PDF Backgrounds & Foregrounds
Passwords, Security and MetaData Editing PDFs Outlines & Bookmarks Annotations Digital Signatures Stamping New Content Watermarking Reading PDF Text Paper Printing PDFs

PDF Generation Settings

// Install IronPdf with Nuget:  PM> Install-Package IronPdf
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");
' Install IronPdf with Nuget:  PM> Install-Package IronPdf
Imports IronPdf

Private 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")
Read more
Try IronPDF free for development
Download Free
C# Object Reference and Get Started Tutorials
Object Reference
C# Library Licensing
Licensing
.Net Developer Support
Ask a Question

PDF Generation Settings

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

Previous Example
Next Example

The C# PDF solution you've been looking for.

.Net Developer Support

Support

Open a support ticket with our development team.

Ask a Question
C# Object Reference and Get Started Tutorials

Documentation

View code examples and tutorials.

Get Started
C# Library Licensing

Licensing

Free for development. License from $399.

See Licenses
Install The C# PDF library

Try IronPDF Free

Get set up in 5 minutes.

Download
Try IronPDF for Free
Get Set Up in 5 Minutes
C# Nuget Library for PDF
Install with NuGet
Version 2021.3.1
Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL
Version 2021.3.1
Download Now
Manually install into your project
  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"
Licenses from $399

Have a question? Get in touch with our development team.

Now that you’ve downloaded IronPDF
Want to deploy IronPDF to a live project for FREE ?
IronPDF is always free for development.
With a deployment trial license, you can test and share your project in a live environment with no watermarks.
Get your free
30-day Trial License Key
instantly.
Your Trial License Key has been emailed to you.
Full licenses for every project,
starting from $399
View Licenses
Have a question? Get in touch with our development team.
Want to deploy IronPDF to a live project for FREE ?
IronPDF is always free for development.
With a deployment trial license, you can test and share your project in a live environment with no watermarks.
Get your free
30-day Trial License Key
instantly.
Your Trial License Key has been emailed to you.
Download IronPDF free to apply
your Trial Licenses Key
Install with Nuget DLL Download
Licenses from $399. Have a question? Get in touch.
Install with Nuget
Iron Software LLC
205 N. Michigan Ave.
Chicago, IL 60611 USA
Copyright ©  2013-2021
Terms
|
Privacy
IronPDF IronOCR IronBarcode IronXL IronWebScraper
About Us Contact Us
IronPDF
Ask a Question Documentation Tutorials API Reference
Licensing
Get Licensed Support & Updates Extensions Using License Keys EULA Credits