A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://103.13.28.148/cstovb/cstovb/): failed to open stream: HTTP request failed!

Filename: libraries/Converter.php

Line Number: 134

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 134
Function: file_get_contents

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: libraries/Converter.php

Line Number: 136

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 136
Function: strpos

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://103.13.28.148/cstovb/cstovb/): failed to open stream: HTTP request failed!

Filename: libraries/Converter.php

Line Number: 134

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 134
Function: file_get_contents

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: libraries/Converter.php

Line Number: 136

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 136
Function: strpos

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://103.13.28.148/cstovb/cstovb/): failed to open stream: HTTP request failed!

Filename: libraries/Converter.php

Line Number: 134

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 134
Function: file_get_contents

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: libraries/Converter.php

Line Number: 136

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 136
Function: strpos

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://103.13.28.148/cstovb/cstovb/): failed to open stream: HTTP request failed!

Filename: libraries/Converter.php

Line Number: 134

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 134
Function: file_get_contents

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: libraries/Converter.php

Line Number: 136

Backtrace:

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 136
Function: strpos

File: /var/www/ironpdf.com/application/libraries/Converter.php
Line: 92
Function: convert_cs_to_vb_with_vbconverter

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 1814
Function: convert_cs_to_vb

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 559
Function: render_cs_window

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 532
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 561
Function: {closure}

File: /var/www/ironpdf.com/application/libraries/MarkdownProcessor.php
Line: 28
Function: render_language_type

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 340
Function: processMarkdownViewContent

File: /var/www/ironpdf.com/application/controllers/Products/Blog.php
Line: 77
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

Generate PDF Dynamically in C# (Developer Guide)Skip to footer content
USING IRONPDF

How to Dynamically Generate PDFs in C#

Modern web applications demand more than static document creation. Whether generating personalized invoices, creating data-driven PDF reports, or producing customized form fields, developers need robust tools to generate PDF documents at runtime. IronPDF emerges as the leading solution, offering powerful Chrome-based rendering to create PDF documents with seamless C# integration for dynamic PDF generation in C# and .NET Framework environments.

How to Dynamically Generate PDFs in C#: Figure 1 - Cross Platform

What is Dynamic PDF Generation in C#?

Dynamic PDF generation in C# creates PDF documents at runtime using variable data from multiple data sources, including databases, APIs, or user inputs. Unlike static PDF files, runtime generation enables personalized content, conditional sections, and data-driven layouts, these are essential for invoices, PDF reports, certificates, and forms that adapt to changing requirements. This approach to programmatically create a PDF has become crucial for modern .NET Framework and .NET Core applications.

How to Dynamically Generate PDFs in C#: Figure 2 - Cross Platform

Getting Started with IronPDF

Begin by installing the IronPDF NuGet package through Package Manager Console in Visual Studio:

Install-Package IronPdf

How to Dynamically Generate PDFs in C#: Figure 3 - Installation

Or use the NuGet Package Manager interface to download and install. Initialize the ChromePdfRenderer for pixel-perfect PDF generation:

using IronPdf;
// Create Chrome renderer instance
var renderer = new ChromePdfRenderer();
// Configure rendering options for PDF format
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
using IronPdf;
// Create Chrome renderer instance
var renderer = new ChromePdfRenderer();
// Configure rendering options for PDF format
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

The ChromePdfRenderer class provides the foundation to generate a PDF at runtime. Setting margins ensures space for headers and footers, while PrintHtmlBackgrounds preserves design elements. This configuration helps create PDF documents based on HTML content exactly. Learn more about rendering options to customize your PDF documents.

How to Dynamically Create PDF Documents using a Template

Create reusable HTML templates with placeholders for dynamic data injection:

// Define HTML string template with placeholders
string invoiceTemplate = @"
<html>
<body>
    <h1>Invoice #[[INVOICE_NUMBER]]</h1>
    <p>Date: [[DATE]]</p>
    <p>Customer: [[CUSTOMER_NAME]]</p>
    <table>
        <tr><th>Item</th><th>Price</th></tr>
        [[ITEMS]]
    </table>
    <p><strong>Total: $[[TOTAL]]</strong></p>
</body>
</html>";
// Replace placeholders with dynamic data
var invoiceData = new {
    InvoiceNumber = "INV-2025-001",
    Date = DateTime.Now.ToString("yyyy-MM-dd"),
    CustomerName = "John Doe",
    Total = 1250.00m
};
string finalHtml = invoiceTemplate
    .Replace("[[INVOICE_NUMBER]]", invoiceData.InvoiceNumber)
    .Replace("[[DATE]]", invoiceData.Date)
    .Replace("[[CUSTOMER_NAME]]", invoiceData.CustomerName)
    .Replace("[[TOTAL]]", invoiceData.Total.ToString());
// Generate PDF from populated HTML content
var pdf = renderer.RenderHtmlAsPdf(finalHtml);
pdf.SaveAs("invoice.pdf");
// Define HTML string template with placeholders
string invoiceTemplate = @"
<html>
<body>
    <h1>Invoice #[[INVOICE_NUMBER]]</h1>
    <p>Date: [[DATE]]</p>
    <p>Customer: [[CUSTOMER_NAME]]</p>
    <table>
        <tr><th>Item</th><th>Price</th></tr>
        [[ITEMS]]
    </table>
    <p><strong>Total: $[[TOTAL]]</strong></p>
</body>
</html>";
// Replace placeholders with dynamic data
var invoiceData = new {
    InvoiceNumber = "INV-2025-001",
    Date = DateTime.Now.ToString("yyyy-MM-dd"),
    CustomerName = "John Doe",
    Total = 1250.00m
};
string finalHtml = invoiceTemplate
    .Replace("[[INVOICE_NUMBER]]", invoiceData.InvoiceNumber)
    .Replace("[[DATE]]", invoiceData.Date)
    .Replace("[[CUSTOMER_NAME]]", invoiceData.CustomerName)
    .Replace("[[TOTAL]]", invoiceData.Total.ToString());
// Generate PDF from populated HTML content
var pdf = renderer.RenderHtmlAsPdf(finalHtml);
pdf.SaveAs("invoice.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

This template approach separates presentation from data, enabling designers to modify complex layouts while developers focus on data integration. The Replace method substitutes template ID placeholders with runtime values, creating personalized PDF documents. For converting HTML content with repeating sections, build the HTML dynamically using loops before PDF conversion. Explore more HTML to PDF examples for advanced templating.

Output

How to Dynamically Generate PDFs in C#: Figure 4 - PDF Output

Advanced Data Binding with Async Processing

Scale your PDF generation with async methods for high-volume processing:

// Async batch generation for multiple PDF documents
public async Task GenerateMonthlyReportsAsync(List<Customer> customers)
{
    var renderer = new ChromePdfRenderer();
    var tasks = new List<Task>();
    foreach (var customer in customers)
    {
        tasks.Add(Task.Run(async () =>
        {
            // Create HTML content with dynamic data
            string html = $@"
                <h2>Monthly Report - {customer.Name}</h2>
                <p>Account Balance: ${customer.Balance:F2}</p>
                <p>Transactions: {customer.TransactionCount}</p>
                <div style='page-break-after: always;'></div>";
            // Convert HTML to PDF format
            var document = await renderer.RenderHtmlAsPdfAsync(html);
            await document.SaveAs($"reports/{customer.Id}_report.pdf");
        }));
    }
    await Task.WhenAll(tasks);
}
// Async batch generation for multiple PDF documents
public async Task GenerateMonthlyReportsAsync(List<Customer> customers)
{
    var renderer = new ChromePdfRenderer();
    var tasks = new List<Task>();
    foreach (var customer in customers)
    {
        tasks.Add(Task.Run(async () =>
        {
            // Create HTML content with dynamic data
            string html = $@"
                <h2>Monthly Report - {customer.Name}</h2>
                <p>Account Balance: ${customer.Balance:F2}</p>
                <p>Transactions: {customer.TransactionCount}</p>
                <div style='page-break-after: always;'></div>";
            // Convert HTML to PDF format
            var document = await renderer.RenderHtmlAsPdfAsync(html);
            await document.SaveAs($"reports/{customer.Id}_report.pdf");
        }));
    }
    await Task.WhenAll(tasks);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

The async pattern enables concurrent PDF generation, dramatically improving throughput when you generate PDF documents in batch. Task.WhenAll ensures all PDF files are complete before proceeding. The above code uses CSS page-break properties to control pagination, ensuring each customer's report starts on a new page. Review the async PDF generation documentation for enterprise web applications.

Creating Interactive PDF Forms Dynamically

Transform web pages with HTML forms into fillable PDFs programmatically:

// Enable form fields creation in rendering options
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
// Define HTML string with form elements
string formHtml = @"
<form>
    <h2>Customer Survey</h2>
    <label>Name: 
    <label>Email: 
    <label>Satisfaction:
        <select name='satisfaction'>
            <option>Excellent</option>
            <option>Good</option>
            <option>Fair</option>
        </select>
    </label><br>
    <label>Comments: <textarea name='comments'></textarea></label>
</form>";
// Create a PDF with interactive form fields
var pdfDocument = renderer.RenderHtmlAsPdf(formHtml);
pdfDocument.SaveAs("survey_form.pdf");
// Enable form fields creation in rendering options
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
// Define HTML string with form elements
string formHtml = @"
<form>
    <h2>Customer Survey</h2>
    <label>Name: 
    <label>Email: 
    <label>Satisfaction:
        <select name='satisfaction'>
            <option>Excellent</option>
            <option>Good</option>
            <option>Fair</option>
        </select>
    </label><br>
    <label>Comments: <textarea name='comments'></textarea></label>
</form>";
// Create a PDF with interactive form fields
var pdfDocument = renderer.RenderHtmlAsPdf(formHtml);
pdfDocument.SaveAs("survey_form.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Setting CreatePdfFormsFromHtml converts HTML form elements into interactive PDF form fields. Users can fill, save, and submit these PDF documents electronically. This feature streamlines workflows by eliminating paper forms while maintaining familiar HTML development patterns. The PDFDocument object provides access to manipulate form fields programmatically. Learn about PDF forms manipulation for advanced implementations, including digital signatures.

Output

How to Dynamically Generate PDFs in C#: Figure 5 - Interactive PDF Form Output

Why Choose IronPDF Over Other Methods

IronPDF's Chrome rendering engine ensures pixel-perfect accuracy when you create PDFs, eliminating the compromises of older WebKit rendering engine solutions. Unlike open source library alternatives requiring external executables or headless browser setups, IronPDF integrates seamlessly with zero dependencies. The fluent API and high-level API design make it superior to built-in classes or complex Crystal Reports implementations.

How to Dynamically Generate PDFs in C#: Figure 6 - Features

Key advantages for dynamic PDF generation in C#

  • Full JavaScript execution, unlike other methods
  • Thread-safe operations for web applications
  • Comprehensive async support with the following example patterns
  • Page numbers and font size control through a simple API endpoint configuration
  • HTML to PDF conversion matches Chrome exactly

How to Dynamically Generate PDFs in C#: Figure 7 - Dynamic PDF Generation - IronPDF

Licensing starts at $799 for single-developer licenses, with team and enterprise options available. Each package has its own advantages, and the investment pays for itself through development time savings. Access your API key instantly upon purchase. View licensing options to find the right NuGet package for your project.

How to Dynamically Generate PDFs in C#: Figure 8 - Licensing

Conclusion

Dynamic PDF generation in C# transforms how applications deliver personalized documents at runtime. IronPDF provides essential tools to generate PDF files from HTML content, web pages, and data sources. Its Chrome-based rendering ensures your PDFs in C# match design specifications exactly, while async support enables enterprise-scale processing.

The following command starts your journey: Install-Package IronPdf. With IronPDF, you can convert HTML strings, create complex PDFs with images and tables, add page numbers, control font size, and generate PDF reports from any data source. Each new document benefits from pixel-perfect rendering, whether creating a simple var page or complex layouts with multiple var document instances.

Start with IronPDF's free 30-day trial bundle.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of ...Read More
Ready to Get Started?
Nuget Downloads 15,824,053 | Version: 2025.10 just released