IronPDF in C#Photo from Unsplash

Originally Posted On: https://ironpdf.com/blog/migration-guides/migrate-from-questpdf-to-ironpdf/

How to Migrate from QuestPDF to IronPDF in C#

Migrating from QuestPDF to IronPDF transforms your PDF generation workflow from a proprietary C# fluent API to a standard HTML/CSS-based approach with comprehensive PDF manipulation capabilities. This guide provides a complete, step-by-step migration path that enables you to leverage existing web skills, reuse HTML templates, and gain features that QuestPDF simply cannot provide.

Why Migrate from QuestPDF to IronPDF

Understanding QuestPDF

QuestPDF is a modern, fluent API created specifically for generating PDFs programmatically in C#. Unlike some of its peers that offer comprehensive HTML-to-PDF conversion capability, QuestPDF is limited to programmatic layout API functionalities. QuestPDF excels in scenarios where developers need to generate documents from scratch using C# code, without relying on HTML.

The library is free for businesses with revenue under $1M, but it comes with a requirement to prove this revenue level, which could be a compliance burden for some. Users who surpass this threshold need to purchase a license, which must be factored into long-term planning when evaluating QuestPDF as a potential solution.

The Core Problem: No HTML Support

QuestPDF is often recommended for HTML-to-PDF conversion, but it doesn’t support HTML at all. Despite being heavily promoted on developer forums, QuestPDF uses its own proprietary layout language that requires learning an entirely new DSL instead of leveraging existing web skills.

Feature QuestPDF IronPDF
HTML-to-PDF NOT SUPPORTED Full support
CSS Styling NOT SUPPORTED Full CSS3
Existing Templates Must rebuild from scratch Reuse HTML/CSS assets
Design Tool Compatibility None Any web design tool
Learning Curve New proprietary DSL Web skills transfer
Layout Preview Requires IDE plugin Preview in any browser
PDF Manipulation None Merging, splitting, editing

IronPDF provides native HTML-to-PDF rendering that QuestPDF completely lacks, eliminating the need to manually reconstruct documents in C# code. It includes comprehensive PDF manipulation features (merge, split, edit, secure) that QuestPDF cannot perform.

The QuestPDF Licensing Model

QuestPDF’s “Community License” is only free if your company has less than $1 million in annual gross revenue. Your clients (not just you as a developer) may need to purchase licenses if they exceed revenue thresholds. Unlike a simple per-developer commercial license, QuestPDF’s model requires revenue disclosure and compliance tracking.

IronPDF offers simple licensing: one license per developer, no revenue audits, no client licensing requirements, and clear, predictable costs.

For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides transparent licensing without revenue-based audits and a standard HTML/CSS approach that leverages existing web development skills.

Before You Start

Prerequisites

  1. .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet Access: Ability to install NuGet packages
  3. IronPDF License: Obtain your license key from ironpdf.com

NuGet Package Changes

  1. # Remove QuestPDF
  2. dotnet remove package QuestPDF
  3. # Add IronPDF
  4. dotnet add package IronPdf
SHELL

License Configuration

  1. // Add at application startup
  2. IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

Find QuestPDF Usage

  1. # Find all QuestPDF usages in your codebase
  2. grep -r "QuestPDF|Document.Create|.GeneratePdf" --include="*.cs" .

Complete API Reference

Namespace Changes

  1. // Before: QuestPDF
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Helpers;
  4. using QuestPDF.Infrastructure;
  5. // After: IronPDF
  6. using IronPdf;

Core API Mappings

QuestPDF Concept IronPDF Equivalent Notes
Document.Create() new ChromePdfRenderer() Renderer creation
.Page() RenderHtmlAsPdf() Renders HTML to PDF
.Text() HTML <p>, <h1>, <span> Standard HTML tags
.Bold() CSS font-weight: bold Standard CSS
.FontSize(24) CSS font-size: 24px Standard CSS
.Image() HTML <img src="..."> Standard HTML
.Table() HTML <table> Standard HTML
.Column() CSS display: flex; flex-direction: column CSS Flexbox
.Row() CSS display: flex; flex-direction: row CSS Flexbox
PageSizes.A4 RenderingOptions.PaperSize Paper dimensions
.Margin() RenderingOptions.Margin* Page margins
.GeneratePdf() pdf.SaveAs() File output
N/A PdfDocument.Merge() Merge PDFs
N/A PdfDocument.FromFile() Load existing PDFs
N/A pdf.SecuritySettings PDF encryption

Code Migration Examples

Example 1: Basic Document Creation (HTML-to-PDF)

Before (QuestPDF):

  1. // NuGet: Install-Package QuestPDF
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Helpers;
  4. using QuestPDF.Infrastructure;
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. QuestPDF.Settings.License = LicenseType.Community;
  10. Document.Create(container =>
  11. {
  12. container.Page(page =>
  13. {
  14. page.Size(PageSizes.A4);
  15. page.Margin(2, Unit.Centimetre);
  16. page.Content().Column(column =>
  17. {
  18. column.Item().Text("Hello World").FontSize(20).Bold();
  19. column.Item().Text("This is a paragraph of text.");
  20. });
  21. });
  22. }).GeneratePdf("output.pdf");
  23. }
  24. }

After (IronPDF):

  1. // NuGet: Install-Package IronPdf
  2. using IronPdf;
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. var renderer = new ChromePdfRenderer();
  8. var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is a paragraph of text.</p>");
  9. pdf.SaveAs("output.pdf");
  10. }
  11. }

This example demonstrates the fundamental paradigm difference. QuestPDF requires learning its fluent API: Document.Create(), container.Page(), page.Content().Column(), column.Item().Text(), with styling via method chaining like .FontSize(20).Bold(). You must also set the license type with QuestPDF.Settings.License = LicenseType.Community.

IronPDF uses standard HTML that any web developer knows: <h1> for headings, <p> for paragraphs. No proprietary DSL to learn. IronPDF’s approach offers cleaner syntax and better integration with modern .NET applications. See the HTML to PDF documentation for comprehensive examples.

Example 2: Invoice Generation

Before (QuestPDF):

  1. // NuGet: Install-Package QuestPDF
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Helpers;
  4. using QuestPDF.Infrastructure;
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. QuestPDF.Settings.License = LicenseType.Community;
  10. Document.Create(container =>
  11. {
  12. container.Page(page =>
  13. {
  14. page.Size(PageSizes.A4);
  15. page.Margin(2, Unit.Centimetre);
  16. page.Content().Column(column =>
  17. {
  18. column.Item().Text("INVOICE").FontSize(24).Bold();
  19. column.Item().Text("Invoice #: 12345").FontSize(12);
  20. column.Item().PaddingTop(20);
  21. column.Item().Text("Customer: John Doe");
  22. column.Item().Text("Total: $100.00").Bold();
  23. });
  24. });
  25. }).GeneratePdf("invoice.pdf");
  26. }
  27. }

After (IronPDF):

  1. // NuGet: Install-Package IronPdf
  2. using IronPdf;
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. var htmlContent = @"
  8. <h1>INVOICE</h1>
  9. <p>Invoice #: 12345</p>
  10. <br/>
  11. <p>Customer: John Doe</p>
  12. <p><strong>Total: $100.00</strong></p>
  13. ";
  14. var renderer = new ChromePdfRenderer();
  15. var pdf = renderer.RenderHtmlAsPdf(htmlContent);
  16. pdf.SaveAs("invoice.pdf");
  17. }
  18. }

QuestPDF uses .Column() and .Item() for layout, with .PaddingTop(20) for spacing. IronPDF uses standard HTML: <h1> for the title, <p> for paragraphs, <br/> for spacing, and <strong> for bold text.

The real advantage: with IronPDF, designers can create and modify HTML templates independently. With QuestPDF, every design change requires a C# developer to modify code. Learn more in our tutorials.

Example 3: Headers and Footers with Page Numbers

Before (QuestPDF):

  1. // NuGet: Install-Package QuestPDF
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Helpers;
  4. using QuestPDF.Infrastructure;
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. QuestPDF.Settings.License = LicenseType.Community;
  10. Document.Create(container =>
  11. {
  12. container.Page(page =>
  13. {
  14. page.Size(PageSizes.A4);
  15. page.Margin(2, Unit.Centimetre);
  16. page.Header().Text("Document Header").FontSize(14).Bold();
  17. page.Content().Text("Main content of the document.");
  18. page.Footer().AlignCenter().Text(text =>
  19. {
  20. text.Span("Page ");
  21. text.CurrentPageNumber();
  22. });
  23. });
  24. }).GeneratePdf("document.pdf");
  25. }
  26. }

After (IronPDF):

  1. // NuGet: Install-Package IronPdf
  2. using IronPdf;
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. var htmlContent = "<p>Main content of the document.</p>";
  8. var renderer = new ChromePdfRenderer();
  9. var pdf = renderer.RenderHtmlAsPdf(htmlContent);
  10. pdf.Header = new TextHeaderFooter()
  11. {
  12. CenterText = "Document Header",
  13. FontSize = 14
  14. };
  15. pdf.Footer = new TextHeaderFooter()
  16. {
  17. CenterText = "Page {page}"
  18. };
  19. pdf.SaveAs("document.pdf");
  20. }
  21. }

QuestPDF uses page.Header() and page.Footer() with fluent methods like .AlignCenter() and .CurrentPageNumber(). IronPDF uses TextHeaderFooter objects with properties like CenterText and FontSize. The {page} placeholder automatically inserts the current page number.

Critical Migration Notes

The Paradigm Shift

The fundamental change is moving from a proprietary C# DSL to standard HTML/CSS:

  1. // QuestPDF: Proprietary fluent API
  2. container.Page(page =>
  3. {
  4. page.Content().Column(column =>
  5. {
  6. column.Item().Text("Invoice").Bold().FontSize(24);
  7. column.Item().Row(row =>
  8. {
  9. row.RelativeItem().Text("Customer:");
  10. row.RelativeItem().Text("Acme Corp");
  11. });
  12. });
  13. });
  14. // IronPDF: Standard HTML/CSS
  15. var html = @"
  16. <div style='font-family: Arial; padding: 40px;'>
  17. <h1 style='font-weight: bold; font-size: 24px;'>Invoice</h1>
  18. <div style='display: flex; justify-content: space-between;'>
  19. <span>Customer:</span>
  20. <span>Acme Corp</span>
  21. </div>
  22. </div>";
  23. var renderer = new ChromePdfRenderer();
  24. var pdf = renderer.RenderHtmlAsPdf(html);

Layout Pattern Conversions

QuestPDF Pattern HTML/CSS Equivalent
.Column() display: flex; flex-direction: column
.Row() display: flex; flex-direction: row
.RelativeItem() flex: 1
.Table() <table> element
.PaddingTop(20) padding-top: 20px or <br/>
.AlignCenter() text-align: center
.FontSize(24) font-size: 24px
.Bold() font-weight: bold or <strong>

Page Settings Conversion

  1. // QuestPDF
  2. page.Size(PageSizes.A4);
  3. page.Margin(2, Unit.Centimetre);
  4. // IronPDF
  5. var renderer = new ChromePdfRenderer();
  6. renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
  7. renderer.RenderingOptions.MarginTop = 20; // mm (2cm = 20mm)
  8. renderer.RenderingOptions.MarginBottom = 20;
  9. renderer.RenderingOptions.MarginLeft = 20;
  10. renderer.RenderingOptions.MarginRight = 20;

New Capabilities After Migration

After migrating to IronPDF, you gain capabilities that QuestPDF cannot provide:

PDF Merging

  1. var cover = renderer.RenderHtmlAsPdf("<h1>Cover</h1>");
  2. var content = renderer.RenderHtmlAsPdf(reportHtml);
  3. var existing = PdfDocument.FromFile("appendix.pdf");
  4. var merged = PdfDocument.Merge(cover, content, existing);
  5. merged.SaveAs("complete.pdf");

PDF Security

  1. var pdf = renderer.RenderHtmlAsPdf(html);
  2. pdf.SecuritySettings.OwnerPassword = "admin";
  3. pdf.SecuritySettings.UserPassword = "reader";
  4. pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
  5. pdf.SaveAs("protected.pdf");

URL to PDF

  1. var renderer = new ChromePdfRenderer();
  2. renderer.RenderingOptions.EnableJavaScript = true;
  3. var pdf = renderer.RenderUrlAsPdf("https://example.com/report");
  4. pdf.SaveAs("webpage.pdf");

Load and Edit Existing PDFs

  1. var pdf = PdfDocument.FromFile("existing.pdf");
  2. // Modify, merge, add security, etc.
  3. pdf.SaveAs("modified.pdf");

Feature Comparison Summary

Feature QuestPDF IronPDF
HTML-to-PDF Not supported Primary feature
Learning Curve Proprietary DSL Standard web skills
Template Preview Plugin required Any browser
Design Collaboration Developers only Designers + Developers
Existing Assets Must rebuild Reuse HTML/CSS
PDF Manipulation Not supported Full support
Security/Signing Not supported Full support
Licensing Model Revenue-based Per-developer
Client Impact May need licenses None
Bootstrap/Tailwind Not supported Full support
URL to PDF Not supported Full support

Migration Checklist

Pre-Migration

  • Identify all QuestPDF document templates (Document.Create, .GeneratePdf)
  • Document the DSL patterns used (.Column(), .Row(), .Table(), .Text())
  • Map styling methods to CSS equivalents
  • Obtain IronPDF license key from ironpdf.com

Package Changes

  • Remove QuestPDF NuGet package
  • Install IronPdf NuGet package: dotnet add package IronPdf

Code Changes

  • Update namespace imports
  • Remove QuestPDF.Settings.License = LicenseType.Community
  • Convert Document.Create() pattern to ChromePdfRenderer + HTML
  • Replace .Column() / .Row() with CSS Flexbox
  • Replace .Table() with HTML <table> elements
  • Convert .Text().Bold().FontSize(24) to <h1 style='...'>
  • Replace page.Header() / page.Footer() with TextHeaderFooter
  • Replace .CurrentPageNumber() with {page} placeholder
  • Convert .GeneratePdf() to pdf.SaveAs()
  • Add license initialization at application startup

Post-Migration

  • Visual comparison of PDF output
  • Test multi-page documents for correct page breaks
  • Add new capabilities (security, merging, URL-to-PDF) as needed