IronPDF Quickstart Guide
Install IronPDF and create your first PDF in just five minutes. With its simple API, you can convert HTML, DOCX, images, and more into pixel-perfect PDFs.
1. Prerequisites
- .NET Framework 4.6.2+ OR .NET Core 3.1+ OR .NET 5+
- Visual C++ Redistributable (for Windows).
2. Install IronPDF
Standard IronPDF installation runs locally. If you want to deploy on Docker/microservices, check out Remote Engine Mode Guide.
-
1Install IronPDF with NuGet Package Manager
-
2Copy and run this code snippet.
IronPdf.ChromePdfRenderer .StaticRenderHtmlAsPdf("<p>Hello World</p>") .SaveAs("pixelperfect.pdf");Dim Renderer = New IronPdf.ChromePdfRenderer() Renderer.StaticRenderHtmlAsPdf("<p>Hello World</p>").SaveAs("pixelperfect.pdf")Dim Renderer = New IronPdf.ChromePdfRenderer() Renderer.StaticRenderHtmlAsPdf("<p>Hello World</p>").SaveAs("pixelperfect.pdf") -
3Deploy to test on your live environment
Start using IronPDF in your project today with a free trial
Go to the IronPDF NuGet library:
- In Solution Explorer, right-click on References
- Select 'Manage NuGet Packages' > 'Browse' > Search IronPDF
- Download IronPDF DLL package
- Unzip the ZIP file for your OS to a location within your Solution directory
- In Visual Studio Solution Explorer, right-click on 'Dependencies'
- 'Add Project Reference' > Select 'Browse' to include all the DLLs extracted from the zip.
Platform-specific Guides
3. Apply License Key
When you purchase IronPDF licenses or choose to start with a 30-day trial, a license key will be sent to your email. Copy the key and add it at the start of your app.
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";Imports IronPdf
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"Imports IronPdf
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"4. Create Your First PDF
Add this at the top of your .cs file.
using IronPdf;using IronPdf;Imports IronPdfImports IronPdfThe simplest way to create a PDF object uses just the width and height. This PdfDocument constructor creates a blank PDF, ready for customization.
using IronPdf;
PdfDocument pdf = new PdfDocument(270, 270);
pdf.SaveAs("blankPage.pdf");using IronPdf;
PdfDocument pdf = new PdfDocument(270, 270);
pdf.SaveAs("blankPage.pdf");Imports IronPdf
Dim pdf As New PdfDocument(270, 270)
pdf.SaveAs("blankPage.pdf")Imports IronPdf
Dim pdf As New PdfDocument(270, 270)
pdf.SaveAs("blankPage.pdf")Using ChromePdfRenderer.RenderHtmlAsPdf method, you can transform any HTML (including HTML5) into a PDF using the embedded Chromium engine.
using IronPdf;
IronPdf.ChromePdfRenderer
.StaticRenderHtmlAsPdf("<p>Hello World</p>")
.SaveAs("string-to-pdf.pdf");using IronPdf;
IronPdf.ChromePdfRenderer
.StaticRenderHtmlAsPdf("<p>Hello World</p>")
.SaveAs("string-to-pdf.pdf");Dim Renderer = New IronPdf.ChromePdfRenderer()
Renderer.StaticRenderHtmlAsPdf("<p>Hello World</p>").SaveAs("string-to-pdf.pdf")Dim Renderer = New IronPdf.ChromePdfRenderer()
Renderer.StaticRenderHtmlAsPdf("<p>Hello World</p>").SaveAs("string-to-pdf.pdf")Convert Word documents to PDF with the DocxToPdfRenderer class, you can render DOCX files directly into customizable PDFs for seamless integration into .NET apps.
using IronPdf;
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
pdf.SaveAs("pdfFromDocx.pdf");using IronPdf;
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
pdf.SaveAs("pdfFromDocx.pdf");Imports IronPdf
Private renderer As New DocxToPdfRenderer()
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
pdf.SaveAs("pdfFromDocx.pdf")Imports IronPdf
Private renderer As New DocxToPdfRenderer()
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
pdf.SaveAs("pdfFromDocx.pdf")5. More Advanced Examples
In addition to straightforward PDF creation and conversion, IronPDF also offers more powerful PDF customization options.
Create text headers or footers by instantiating TextHeaderFooter, adding your text, and attaching it to the PDF.
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>");
// Create text header
TextHeaderFooter textHeader = new TextHeaderFooter
{
CenterText = "This is the header!",
};
// Create text footer
TextHeaderFooter textFooter = new TextHeaderFooter
{
CenterText = "This is the footer!",
};
// Add text header and footer to the PDF
pdf.AddTextHeaders(textHeader);
pdf.AddTextFooters(textFooter);
pdf.SaveAs("addTextHeaderFooter.pdf");using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>");
// Create text header
TextHeaderFooter textHeader = new TextHeaderFooter
{
CenterText = "This is the header!",
};
// Create text footer
TextHeaderFooter textFooter = new TextHeaderFooter
{
CenterText = "This is the footer!",
};
// Add text header and footer to the PDF
pdf.AddTextHeaders(textHeader);
pdf.AddTextFooters(textFooter);
pdf.SaveAs("addTextHeaderFooter.pdf");Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>")
' Create text header
Dim textHeader As New TextHeaderFooter With {
.CenterText = "This is the header!"
}
' Create text footer
Dim textFooter As New TextHeaderFooter With {
.CenterText = "This is the footer!"
}
' Add text header and footer to the PDF
pdf.AddTextHeaders(textHeader)
pdf.AddTextFooters(textFooter)
pdf.SaveAs("addTextHeaderFooter.pdf")Imports IronPdf
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World!</h1>")
' Create text header
Dim textHeader As New TextHeaderFooter With {
.CenterText = "This is the header!"
}
' Create text footer
Dim textFooter As New TextHeaderFooter With {
.CenterText = "This is the footer!"
}
' Add text header and footer to the PDF
pdf.AddTextHeaders(textHeader)
pdf.AddTextFooters(textFooter)
pdf.SaveAs("addTextHeaderFooter.pdf")Redact text with ease using RedactTextOnAllPages to remove a phrase across the entire document.
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric");
pdf.SaveAs("redacted.pdf");using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric");
pdf.SaveAs("redacted.pdf");Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric")
pdf.SaveAs("redacted.pdf")Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'Alaric' phrase from all pages
pdf.RedactTextOnAllPages("Alaric")
pdf.SaveAs("redacted.pdf")Merge two PDF files in C# with the Merge method. Use ReplaceTextOnAllPages on any PdfDocument, new or imported, to swap old text with new.
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>");
string oldText = ".NET6";
string newText = ".NET7";
// Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText);
pdf.SaveAs("replaceText.pdf");using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>");
string oldText = ".NET6";
string newText = ".NET7";
// Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText);
pdf.SaveAs("replaceText.pdf");Imports IronPdf
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>")
Private oldText As String = ".NET6"
Private newText As String = ".NET7"
' Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText)
pdf.SaveAs("replaceText.pdf")Imports IronPdf
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>.NET6</h1>")
Private oldText As String = ".NET6"
Private newText As String = ".NET7"
' Replace text on all pages
pdf.ReplaceTextOnAllPages(oldText, newText)
pdf.SaveAs("replaceText.pdf")Quick Troubleshooting
| Issue | Solution |
|---|---|
| Missing Visual C++ Runtime | Install Visual C++ Redistributable - both x86 and x64 versions required for the Chrome engine |
| License not recognized | Verify with IronPdf.License.IsLicensed property. Ensure license is applied before any IronPDF operations |
| Slow first render | Call IronPdf.Installation.Initialize() at startup to pre-initialize rendering engines |
| Linux/Docker dependencies | Set Installation.LinuxAndDockerDependenciesAutoConfig = true for automatic dependency installation |
Next Steps
Frequently Asked Questions
How do I install IronPDF?
You can install IronPDF using the NuGet Package Manager or by downloading the DLL package. The installation guides detail the steps for each method to ensure smooth setup.
What are the prerequisites for using IronPDF?
IronPDF requires .NET Framework 4.6.2+, .NET Core 3.1+, or .NET 5+. Additionally, the Visual C++ Redistributable is required for Windows.
How can I convert an HTML string to a PDF using IronPDF?
IronPDF uses the ChromePdfRenderer.RenderHtmlAsPdf method to transform HTML, including HTML5, into a PDF efficiently using Chromium rendering.
Can IronPDF work with Docker environments?
Yes, IronPDF can be deployed on Docker or microservices architecture. Check out the Remote Engine Mode Guide available on the IronPDF documentation site for more details.
How can I create a blank PDF using IronPDF?
You can create a blank PDF by initializing a PdfDocument with width and height, which sets up a blank document ready for customization.
What additional PDF customization options does IronPDF offer?
IronPDF provides various customization features such as adding headers and footers, redacting text, and merging PDFs to fit diverse project needs.
How do I apply a license key in IronPDF?
A license key is sent to your email upon purchasing an IronPDF license or starting a trial. Insert this key at the start of your application using IronPdf.License.LicenseKey.
How can I troubleshoot issues with IronPDF?
Common issues like missing Visual C++ Runtime or unrecognized licenses have specific solutions such as installing required components or verifying license application early in code execution.
Can IronPDF convert DOCX files to PDF?
Yes, with IronPDF's DocxToPdfRenderer class, you can seamlessly convert DOCX files to PDF, enhancing the integration capabilities of your .NET applications.
What is the easiest way to merge PDF files using IronPDF?
To merge PDFs, use the Merge method provided by IronPDF. It allows you to easily combine multiple documents in C# applications.
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.