Multi Threaded Generation
import {PdfDocument} from "@ironsoftware/ironpdf";

(async () => {
    const htmlStrings = ["<h1>Html#1</h1>", "<h1>Html#2</h1>", "<h1>Html#3</h1>"];

    // Use Promise.all to render HTML strings asynchronously
    const renderPromises = htmlStrings.map(async (html) => {
        const pdf = await PdfDocument.fromHtml(html);
        // Perform more action to the returned PDF
        return pdf;
    });

    // Wait for all rendering Promises to complete
    const pdfDocuments = await Promise.all(renderPromises);
    
    // Do something with the pdfDocuments
})();
npm i @ironsoftware/ironpdf
Multi Threaded Generation

Multi Threaded Generation

JavaScript and Node.js both support asynchronous processing. So does IronPDF, a .NET PDF library, known for its efficient PDF generation and manipulation capabilities.

Most of IronPDF's methods return promises. Leveraging this, we can render multiple HTML contents, and then use the Promise.all method to wait until all the promises have finished.

Please note that the Promise.all method does not guarantee the success of all promises; it only ensures that the promises have finished.

The await within the .map function is used to wait for the returned PDF documents and perform further edits on the documents. If your goal is solely to render the PDFs without additional processing, the use of async and await may not be necessary.

Explore Asynchronous PDF Generation Code Examples
View on GitHub

Ready to Get Started?

Version:2026.11just released