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.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
IronPdf.ChromePdfRenderer .StaticRenderHtmlAsPdf("<p>Hello World</p>") .SaveAs("pixelperfect.pdf");
Deploy to test on your live environment
Go to the IronPDF NuGet library:
- In Solution Explorer, right-click on References
- Select 'Manage NuGet Packages' > 'Browse' > Search IronPdf
Install-Package 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";
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 IronPdf
The 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");
IRON VB CONVERTER ERROR developers@ironsoftware.com
Using ChromePdfRenderer.RenderHtmlAsPdf
method, you can transform any HTML (including HTML5) into a PDF using the embedded Chromium engine.
using IronPdf;
IronPdf.ChromePdfRender
.StaticRenderHtmlAsPdf("<p>Hello Word</p>")
.SaveAs("string-to-pdf.pdf");
using IronPdf;
IronPdf.ChromePdfRender
.StaticRenderHtmlAsPdf("<p>Hello Word</p>")
.SaveAs("string-to-pdf.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
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")
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");
IRON VB CONVERTER ERROR developers@ironsoftware.com
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")
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")
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 can I set up IronPdfEngine for remote PDF generation?
To set up IronPdfEngine for remote PDF generation, install the `IronPdf.Slim` package from NuGet and configure the connection settings using the `IronPdfConnectionConfiguration` class. This setup allows you to connect your application to the IronPdfEngine instance remotely.
What are the main benefits of using IronPdfEngine with my application?
Using IronPdfEngine with your application allows for remote execution of PDF tasks, helping avoid platform-specific compatibility issues, especially on older systems and mobile platforms. It also eliminates the need for the .NET runtime during execution.
Why might I choose to use IronPdfEngine instead of the native PDF library?
You might choose IronPdfEngine to run performance-intensive PDF functions remotely, reducing compatibility issues with different operating systems and improving performance by leveraging a Chrome-identical renderer for HTML to PDF conversion.
Is horizontal scaling supported in IronPdfEngine?
No, IronPdfEngine currently does not support horizontal scaling, which means it cannot be load-balanced across multiple instances due to the way PDF file binaries are handled in server memory.
Can IronPdfEngine run on different operating systems?
IronPdfEngine is designed to run on Linux systems using Docker containers. However, the binaries are platform-specific, so you need to ensure you are using the correct version for your operating system.
What should I do if my PDF outputs are different when using IronPdfEngine?
PDF outputs may vary slightly due to different operating system behaviors. To minimize differences, ensure you are using the correct Docker image and check for any OS-specific settings that might affect rendering.
How do I ensure my application is using the correct version of IronPdfEngine?
To ensure compatibility, each version of IronPDF requires a matching version of IronPdfEngine. Make sure to update both components simultaneously to avoid cross-version issues.
What are the limitations when using IronPdfEngine on Windows?
When using IronPdfEngine on Windows, you need Linux Containers for Docker and must ensure the server port is reachable. The binaries are platform-specific, and switching to Linux Containers is required.
How do I configure IronPDF to connect to a remote IronPdfEngine server?
To configure IronPDF for a remote server, use Installation.ConnectToIronPdfHost
with the IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer
method, specifying the server's IP and port details.
What package should I use to minimize the application size when using IronPdfEngine?
You should use the `IronPdf.Slim` package from NuGet, as it includes only the necessary components for running IronPDF with IronPdfEngine, thereby reducing the application size.