IRONSOFTWAREHOME

How to Create New PDFs in C# with IronPDF

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronPDF enables C# developers to create new PDF documents programmatically by using the PdfDocument constructor for blank PDFs, importing existing PDFs from various sources, or converting HTML, images, RTF, Markdown, and XML to PDF format. Whether building business reports, generating invoices, or creating dynamic documents from web content, IronPDF provides the tools for PDF generation in .NET applications.

Please note: Last verified on an AMD Ryzen 7 5800U workstation (8 cores / 16 threads, 16 GB RAM, Windows 11, .NET 8, IronPDF 2026.7.2). The PdfDocument constructor API is consistent across supported runtimes (.NET Framework 4.6.2+, .NET Core 3.1+, .NET 5 and later), though performance on older runtimes will differ from the benchmarks below.
Quickstart: Create Your First PDF in C#
// 1. Install IronPDF from NuGet
// 2. Create a blank PDF
var pdf = new IronPdf.PdfDocument(270, 270);

// 3. Or convert HTML to PDF
var renderer = new IronPdf.ChromePdfRenderer();
var pdfFromHtml = renderer.RenderHtmlAsPdf("<h1>Hello PDF!</h1>");

// 4. Save your PDF
pdf.SaveAs("myNewPdf.pdf");
Tips: Working with an AI coding assistant? The AI setup guide shows how to point it at IronPDF's documentation, so the code it writes against this page compiles on the first try.

How Do I Create a Blank PDF?

There are multiple ways to create a PDF object. Start with the simplest method, which requires only the width and height of the PDF. This PdfDocument constructor creates a new blank PDF, ready for customization and use. The dimensions are specified in points (1/72 of an inch), enabling precise sizing for various applications like labels, business cards, or custom document formats.

For developers who need more control over page dimensions, IronPDF supports custom paper sizes and various predefined formats including Letter, A4, and Legal sizes, with page orientation control alongside them.

What Parameters Are Required for a Blank PDF?

using IronPdf;

PdfDocument pdf = new PdfDocument(270, 270);

pdf.SaveAs("blankPage.pdf");

How Fast Is Blank PDF Creation?

MetricBlank A4A4 + MetadataA4 (10 pages)LetterCustom (270×270)
Average create time266.6 ms279.4 ms287.2 ms262.4 ms280.6 ms
Output file size0.60 KB3.82 KB1.79 KB0.60 KB0.60 KB
Memory per call1.62 MB1.61 MB1.64 MB1.61 MB1.62 MB
Pages produced111011
Please note: The table above shows how the snippet performs when you vary the page dimensions, add metadata, or merge multiple blank pages. Each variation runs in its own process; numbers are averaged over 5 iterations after a warm-up.

Creation time stays flat at roughly 260-290 ms across every variation, and file size, not speed, is what moves when you add metadata or pages. Once you've created a blank PDF, you can enhance it with headers and footers, watermarks, or inserted images.


How Can I Import PDF from File?

Before a PDF can be modified or converted, it must first be imported as a PdfDocument object. Use the static FromFile method of the PdfDocument class to accomplish this. Importing PDFs from JSON, byte arrays, streams, and URLs is supported within the same class. This flexibility suits scenarios where you need to merge multiple PDFs, extract specific pages, or modify existing documents.

You can also load PDFs from memory streams for efficient processing without touching the file system.

Which Import Methods Are Available?

using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

pdf.SaveAs("export.pdf");

After importing, you can perform operations like extracting text and images, adding annotations, or applying digital signatures.


My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.

Milan Jovanovic

Microsoft MVP

View case study

IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.

Brent Matzelle

Chief Technology Officer, OPYN

View case study

The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.

David Jones

Lead Software Engineer, Agorus Build

View case study

How Do I Convert from Other Formats?

In addition to the previously mentioned methods for obtaining a PdfDocument object, you can convert various formats into PDF. The main method is converting HTML to PDF, which renders the HTML along with all its assets, including JavaScript, images, links, and CSS styling, using the Chrome engine. Besides HTML, you can convert other formats into PDFs, such as images, RTF, Markdown, and XML.

IronPDF's Chrome rendering engine ensures highly accurate conversions that preserve the visual fidelity of your source content. The renderer supports modern web standards including HTML5, CSS3, and JavaScript frameworks, making it suitable for converting complex web pages or Razor views into PDFs.

The following code snippet demonstrates converting HTML to PDF. The HTML conversion uses IronPDF's rendering engine to maintain content integrity with all styling applied. The format list below covers Markdown, XML, and image conversion as well.

What Rendering Options Should I Configure?

Set RenderingOptions on the renderer before the call: paper size, margins, and header or footer HTML all live there.

using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.PaperFit.UseResponsiveCssRendering(1800);
renderer.RenderingOptions.WaitFor.RenderDelay(5000);
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

// 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");

Output

Please note: Stick to modern HTML5 in your source. Legacy markup causes layout glitches in every Chromium-based renderer, IronPDF included. If something renders strangely, run the HTML through a validator first.

Which Formats Can Be Converted to PDF?

IronPDF supports conversion from multiple formats:

Conclusion

A PdfDocument starts from a constructor, an import, or a conversion, and every route ends at the same object: create it blank and stamp content on, load it with FromFile and edit, or render it from HTML, images, RTF, Markdown, or XML. From here, export the result to disk, memory, or an HTTP response, or start from a Word file with DOCX to PDF.

Frequently Asked Questions

How do I create a new PDF in C# using IronPDF?

To create a new PDF in C# with IronPDF, install IronPDF via NuGet, then use the `PdfDocument` constructor for a blank PDF or utilize the `ChromePdfRenderer` for converting HTML to PDF. Save the PDF using the `SaveAs` method.

Can I convert HTML to PDF using IronPDF?

Yes, you can convert HTML to PDF using IronPDF's `ChromePdfRenderer`. This method supports full CSS and JavaScript rendering, ensuring visual fidelity.

What are the available import methods for PDFs in IronPDF?

IronPDF supports importing PDFs from various sources using the `FromFile` method, including file paths, URLs, JSON, byte arrays, and streams.

What formats can be converted to PDF using IronPDF?

IronPDF can convert multiple formats to PDF, including HTML, images (JPG, PNG, GIF, BMP, TIFF), DOCX, RTF, Markdown, XML, and ASP.NET pages like ASPX and Razor pages.

How can I create a blank PDF with specific dimensions using IronPDF?

Use the `PdfDocument` constructor, specifying the width and height in points to create a blank PDF with custom dimensions.

Does IronPDF support PDF creation with custom paper sizes?

Yes, IronPDF allows setting custom paper sizes and offers various predefined formats like Letter, A4, and Legal, with controls for page orientation.

Is it possible to extract text and images from PDFs using IronPDF?

Yes, after importing a PDF into IronPDF, you can extract text and images, add annotations, or apply digital signatures.

What should I configure when converting HTML to PDF using IronPDF?

When using IronPDF to convert HTML to PDF, configure `RenderingOptions` such as paper size, margins, and enabling JavaScript execution to ensure precise rendering.

How fast is creating a blank PDF with IronPDF?

Creating a blank PDF with IronPDF is efficient, taking approximately 260-290 ms depending on the page dimensions and whether metadata or multiple pages are included.

Can IronPDF handle legacy HTML markup in conversions?

IronPDF, like other Chromium-based renderers, can encounter layout issues with legacy HTML. It's recommended to validate HTML before conversion for better results.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 20,878,335Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > 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: 2026.9

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 $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required