IronSoftware
  • Products
    for .NET Java Python
    Create, read, and edit PDFs
    for .NET
    Image to text in 127 languages
    for .NET
    Read and write QR & Barcodes
    for .NET
    Edit Excel & CSV Files.
    No Office Interop required
    for .NET
    Extract structured data from websites
    5 for the Price of 2 All 5 .NET product licenses from $1498 Save 60% with Iron Suite Iron Suites - Donate $50
  • Open Source
    for .NET
    System.Drawing.Common Replacement
    Free Software Development Tools
  • About Us

    Our Company

    • About Us 
    • Company News 
    • Environmental Commitments 
    • Beta Program 
    • Year in Review: 2022 

    Sales Partners

    • Global Resellers 

    Contact Us

    • Live Chat 
    • Send an Email 
    +1 (312) 500-3060
    205 N. Michigan Ave.
    Chicago, IL 60611, USA

    Careers at Iron

    Join our teamJoin our team
    We're hiring
  • Contact Us

205 N. Michigan Ave. Chicago, IL 60611, USA +1 (312) 500-3060

Join Iron Slack

  • Home
  • Licensing
  • EULA
  • Support & Update Extensions
  • License Upgrades
  • Start 30-Day Trial
  • Features
  • Get Started
  • Demos
  • Code Examples
  • Tutorials
  • How-Tos
  • Troubleshooting
  • Product Updates
  • API Reference
  • Search
  • Free NuGet Download
IronPDF Library for C# IronPDF Library for C#
  • IronPDF for Java
  • IronPDF for Python
  • Home
  • Licensing
    • Licensing
    • EULA
    • Support & Update Extensions
    • License Upgrades
    • Start 30-Day Trial
  • Features
  • Docs
    • Search
    • Get Started
    • Demos
    • Code Examples
    • Tutorials
    • How-Tos
    • Troubleshooting
    • Product Updates
    • API Reference
    • Search
  • Search CtrlK
  • Free NuGet Download Total downloads: 7,072,516
Message's icon

C# PDF from HTML

  1. 50+ feature PDF from HTML C# Library
  2. Edit, manipulate, and generate PDF files in C# applications
  3. Compatible with .NET Core, .NET Standard, .NET Framework
Free NuGet Download Total downloads: 7,072,516 Free 30-Day Trial Key Total downloads: 7,072,516
Start for Free Total downloads: 7,072,516

Or download the DLL directly here

Examples

  • C# PDF from HTML File
  • C# PDF Manipulating
  • Add PDF Headers Footers
  • C# PDF Forms
  • C# PDF from URL
  • C# PDF from HTML
  • C# PDF from ASPX
  • C# PDF from Images
  • PDF to Images
  • Responsive HTML to PDF
See All 45 Code Examples
C# PDF from HTML File Run See All 45 Code Examples
using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from an existing HTML file using C#
var pdf = renderer.RenderHtmlFileAsPdf("example.html");

// Export to a file or Stream
pdf.SaveAs("output.pdf");
Install-Package IronPdf
C# PDF Manipulating See All 45 Code Examples
using IronPdf;
using IronPdf.Engines.Chrome;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Many rendering options to use to customize!
renderer.RenderingOptions.SetCustomPaperSizeInInches(12.5, 20);
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Landscape;
renderer.RenderingOptions.Title = "My PDF Document Name";
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.WaitFor.RenderDelay(50); // in milliseconds
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;
renderer.RenderingOptions.FitToPaperMode = FitToPaperModes.Zoom;
renderer.RenderingOptions.Zoom = 100;
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

// Supports margin customization!
renderer.RenderingOptions.MarginTop = 40; //millimeters
renderer.RenderingOptions.MarginLeft = 20; //millimeters
renderer.RenderingOptions.MarginRight = 20; //millimeters
renderer.RenderingOptions.MarginBottom = 40; //millimeters

// Can set FirstPageNumber if you have a cover page
renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page will be appended

// Settings have been set, we can render:
renderer.RenderHtmlFileAsPdf("assets/wikipedia.html").SaveAs("output/my-content.pdf");
Install-Package IronPdf
Add PDF Headers Footers See All 45 Code Examples
using IronPdf;

// Initiate PDF Renderer
var renderer = new ChromePdfRenderer();

// Add a header to every page easily
renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a cover page  will be appended
renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
renderer.RenderingOptions.TextHeader.CenterText = "{url}";
renderer.RenderingOptions.TextHeader.Font = IronSoftware.Drawing.FontTypes.Helvetica;
renderer.RenderingOptions.TextHeader.FontSize = 12;
renderer.RenderingOptions.MarginTop = 25; //create 25mm space for header

// Add a footer too
renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
renderer.RenderingOptions.TextFooter.Font = IronSoftware.Drawing.FontTypes.Arial;
renderer.RenderingOptions.TextFooter.FontSize = 10;
renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
renderer.RenderingOptions.MarginTop = 25; //create 25mm space for footer

// Mergeable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Install-Package IronPdf
C# PDF Forms See All 45 Code Examples
using IronPdf;
using System;

// Step 1.  Creating a PDF with editable forms from HTML using form and input tags
// Radio Button and Checkbox can also be implemented with input type 'radio' and 'checkbox'
const string formHtml = @"
    <html>
        <body>
            <h2>Editable PDF  Form</h2>
            <form>
              First name: <br> <input type='text' name='firstname' value=''> <br>
              Last name: <br> <input type='text' name='lastname' value=''> <br>
              <br>
              <p>Please specify your gender:</p>
              <input type='radio' id='female' name='gender' value= 'Female'>
                <label for='female'>Female</label> <br>
                <br>
              <input type='radio' id='male' name='gender' value='Male'>
                <label for='male'>Male</label> <br>
                <br>
              <input type='radio' id='non-binary/other' name='gender' value='Non-Binary / Other'>
                <label for='non-binary/other'>Non-Binary / Other</label>
              <br>

              <p>Please select all medical conditions that apply:</p>
              <input type='checkbox' id='condition1' name='Hypertension' value='Hypertension'>
              <label for='condition1'> Hypertension</label><br>
              <input type='checkbox' id='condition2' name='Heart Disease' value='Heart Disease'>
              <label for='condition2'> Heart Disease</label><br>
              <input type='checkbox' id='condition3' name='Stoke' value='Stoke'>
              <label for='condition3'> Stoke</label><br>
              <input type='checkbox' id='condition4' name='Diabetes' value='Diabetes'>
              <label for='condition4'> Diabetes</label><br>
              <input type='checkbox' id='condition5' name='Kidney Disease' value='Kidney Disease'>
              <label for='condition5'> Kidney Disease</label><br>
            </form>
        </body>
    </html>";

// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(formHtml).SaveAs("BasicForm.pdf");

// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");

// Set and Read the value of the "firstname" field
var FirstNameField = FormDocument.Form.GetFieldByName("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);

// Set and Read the value of the "lastname" field
IronPdf.Forms.FormField LastNameField = FormDocument.Form.GetFieldByName("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);

FormDocument.SaveAs("FilledForm.pdf");
Install-Package IronPdf
C# PDF from URL Run See All 45 Code Examples
using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from a URL or local file path
var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");

// Export to a file or Stream
pdf.SaveAs("url.pdf");
Install-Package IronPdf
C# PDF from HTML Run See All 45 Code Examples
using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from a HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
Install-Package IronPdf
C# PDF from ASPX See All 45 Code Examples
using IronPdf;

private void Form1_Load(object sender, EventArgs e)
{
    //Changes the ASPX output into a pdf instead of HTML
    IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
Install-Package IronPdf
C# PDF from Images See All 45 Code Examples
using IronPdf;
using System.IO;
using System.Linq;

// One or more images as IEnumerable. This example selects all JPEG images in a specific 'assets' folder.
var imageFiles = Directory.EnumerateFiles("assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg"));

// Converts the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs("composite.pdf");

// Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
Install-Package IronPdf
PDF to Images See All 45 Code Examples
using IronPdf;
using IronSoftware.Drawing;

var pdf = PdfDocument.FromFile("Example.pdf");

// Extract all pages to a folder as image files
pdf.RasterizeToImageFiles(@"C:\image\folder\*.png");

// Dimensions and page ranges may be specified
pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80);
pdf.RasterizeToImageFiles(
    @"C:\image\folder\example_select_pdf_image_*.jpg",   // File Name Pattern
    new List<int>() { 2, 4, 6 },                         // List of Page Numbers
    200,                                                 // Image Width
    160,                                                 // Image Height
    ImageType.Png,                                       // Image Type
    90                                                   // DPI Quality (default is 96 DPI)
);


// Extract all pages as AnyBitmap objects
AnyBitmap[] pdfBitmaps = pdf.ToBitmap();
Install-Package IronPdf
Responsive HTML to PDF See All 45 Code Examples
using IronPdf;
using IronPdf.Engines.Chrome;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Choose Screen or Print CSS media
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;

// Set the width of the responsive virtual browser window in pixels
renderer.RenderingOptions.ViewPortWidth = 1920;

// Set paper mode to automatic fit to physical paper
renderer.RenderingOptions.FitToPaperMode = FitToPaperModes.AutomaticFit;

// Render an HTML file
var pdf = renderer.RenderHtmlFileAsPdf("Assets/Responsive.html");
Install-Package IronPdf

Explore the code and run it to see the sample PDFs

IronPDF

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# API Reference and Get Started Tutorials

Documentation

View code examples and tutorials.

Get Started
C# Library Licensing

Licensing

Free for development. License from $749.

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: 2023.9
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: 2023.9
Download Now
or download Windows Installer here.
  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 $749

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

15 1000 1
Now that you’ve downloaded IronPDF
Want to deploy IronPDF to a live project for FREE?
Not ready to buy?

Want to deploy IronPDF to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No watermarks in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
15 1000 1
Your Trial License Key has been emailed to you.
Not ready to buy?
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
View Licensing
Schedule a call
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
15 1000 1
Want to deploy IronPDF to a live project for FREE?
Not ready to buy?

Want to deploy IronPDF to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No watermarks in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
15 1000 1
Your Trial License Key has been emailed to you.
Not ready to buy?
Download IronPDF free to apply
your Trial Licenses Key
Thank you.
If you'd like to speak to our licensing team:
Install with NuGet View Licensing
Schedule a call
Licenses from $749. Have a question? Get in touch.
Have a question? Get in touch with our development team.
ironpdf_for_dotnet_log2o

Get started for FREE

No credit card required

Fully-functional product

Get 30 days of fully-functional product.
Have it up and running in minutes.

bullet_calendar

Test in a live environment

Test and share in a live environment.
Works wherever you need it to.

bullet_test

No watermarks

No watermarks in production.
No limits.

bullet_watermark
ironpdf_for_dotnet_log2o

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Trusted by Over 2 Million Engineers Worldwide

  • aetna_logo
  • wwf_logo
  • nasa_logo
  • usda_logo
  • 3m_logo
  • tesla_logo
ironpdf_for_dotnet_log2o

Get started for FREE

No credit card required

Fully-functional product

Get 30 days of fully-functional product.
Have it up and running in minutes.

bullet_calendar

Test in a live environment

Test and share in a live environment.
Works wherever you need it to.

bullet_test

No watermarks

No watermarks in production.
No limits.

bullet_watermark
ironpdf_for_dotnet_log2o

Your Trial License Key has been emailed to you.

Install with NuGet
View Licensing

Licenses from $749. Have a question? Get in touch.

Trusted by Over 2 Million Engineers Worldwide

  • aetna_logo
  • wwf_logo
  • nasa_logo
  • usda_logo
  • 3m_logo
  • tesla_logo
Free 30-Day Trial Key Start for Free Start Free Trial Start Free 30-Day Trial Free 30-Day Trial Key Start for Free Start Free Trial Start Free 30-Day Trial

Fully-functional product, get the key instantly

IronPDF for .NET

When you need your PDF to look like HTML, fast.

Search

CtrlK

Documentation

  • Code Examples
  • API Reference
  • How-Tos
  • Features
  • Blog
  • Credits
  • Product Brochure

Tutorials

  • Get Started
  • HTML to PDF
  • Editing PDFs in C#
  • Debug HTML with Chrome
  • ASPX to PDF
  • VB.NET to PDF

Licensing

  • Buy a License
  • Support Extensions
  • Resellers
  • License Keys
  • EULA

Try IronPDF Free

  • Download on NuGet
  • Download DLL

  • Download Windows Installer

  • 30-Day Trial License

When you need your PDF to look like HTML, fast.

Tesseract 5 OCR in the languages you need, We support 127+.

When you need to read, write, and style, QR & Barcodes, fast.

The Excel API you need, without the Office Interop hassle.

The power you need to scrape & output clean, structured data.

The complete .NET Suite for your office.

  • IRONSUITE
  • |
  • IRONPDF
  • IRONOCR
  • IRONBARCODE
  • IRONXL
  • IRONWEBSCRAPER
IronSoftware
205 N. Michigan Ave. Chicago, IL 60611 USA +1 (312) 500-3060
  • About Us
  • News
  • Careers
  • Contact Us
  • Join Iron Slack

Supporting Teamseas

Copyright © Iron Software LLC 2013-2023

  • Terms
  • Privacy

Thank you!

Your license key has been delivered to the email provided. Contact us

24-Hour Upgrade Offer:

Save 50% on a
Professional Upgrade

Go Professional to cover 10 developers
and unlimited projects.

hours

:

minutes

:

seconds

Upgrade to Professional

Upgrade

Professional

$600 USD

$299 USD


  • 10 developers
  • 10 locations
  • 10 projects
TODAY ONLY
Iron Suite

5 .NET Products for the Price of 2

IronPDF IronOCR IronXL IronBarcode IronWebscraper

Total Suite Value:

$7,192 USD

Upgrade price

TODAY
ONLY

$499 USD

After 24 Hrs

$1,098 USD