IRONSOFTWAREHOME
Parallel PDF Generation
using IronPdf;
using System.Collections.Generic;
using System.Threading.Tasks;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

var htmlStrings = new List<string> { "<h1>Html#1</h1>", "<h1>Html#2</h1>", "<h1>Html#3</h1>" };

Parallel.ForEach(htmlStrings, (html) =>
{
    var pdf = renderer.RenderHtmlAsPdf(html);
    // do something with each pdfDocument
});
Imports IronPdf
Imports System.Collections.Generic
Imports System.Threading.Tasks

' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
Dim htmlStrings = New List(Of String) From {"<h1>Html#1</h1>", "<h1>Html#2</h1>", "<h1>Html#3</h1>"}

Parallel.ForEach(htmlStrings, Sub(html)
                                  Dim pdf = renderer.RenderHtmlAsPdf(html)
                                  ' do something with each pdfDocument
                              End Sub)
NuGet Download
PM > Install-Package IronPdf
Parallel PDF Generation

Parallel PDF Generation

Through IronPDF's support for asynchronous, multi-threaded PDF generation, parallel programming is a breeze. Through this, you can do two or more tasks at the same time, or use the Parallel.ForEach loop as we have in this code example for PDF generation.

Steps for Parallel PDF Generation

Here is an example that demonstrates how to use Parallel.ForEach to generate PDFs concurrently:

Explanation

  1. ChromePdfRenderer: The first thing we need to do when using parallel PDF generation with IronPDF is to create a new ChromePdfRenderer instance. This gives us access to the powerful Chromium-based rendering engine and its methods for generating high-quality PDF documents from HTML strings.
  2. HTML Strings List: Next, we define our list of HTML strings, which here contains three HTML strings that we intend to convert into PDF documents.
  3. Parallel Processing: The next step is to use Parallel.ForEach to process these strings concurrently. This allows the application to generate multiple PDF documents simultaneously, significantly improving performance when dealing with a large number of items - such as generating large batches of PDF documents.
  4. Render and Save PDFs: Inside the Parallel.ForEach block, we call the RenderHtmlAsPdf method. This method takes the current HTML string for each iteration through the htmlStrings list and converts it into a PDF document. You can then save the PDF documents or manipulate them further using IronPDF's other PDF editing features.

For more detailed information and example codes, you can refer to IronPDF's How-to Guide.

Explore Asynchronous PDF Generation with IronPDF
View on GitHub

Ready to Get Started?

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

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