# Using the C# `WaitFor` Class to Delay PDF Rendering
The C# `WaitFor` class in IronPDF helps developers delay PDF rendering until all assets, fonts, and JavaScript have loaded, preventing incomplete renders by using methods like `RenderDelay`, `NetworkIdle`, and JavaScript triggers.
*as-heading:2(Quickstart: Using `WaitFor` to Improve PDF Rendering)*
IronPDF's `WaitFor` feature allows developers to improve PDF rendering by managing asynchronous timing. By setting options like `RenderDelay`, you can ensure all assets and scripts are loaded before the conversion, preventing incomplete PDF documents. This guide shows how to implement `WaitFor` in your projects for precise and efficient rendering.
```cs
new IronPdf.ChromePdfRenderer { RenderingOptions = { WaitFor = IronPdf.WaitFor.RenderDelay(3000) } }
.RenderUrlAsPdf("https://example.com")
.SaveAs("output.pdf");
```
<div class="hsg-featured-snippet">
<h3>Minimal Workflow (5 steps)</h3>
<ol>
<li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://www.nuget.org/packages/IronPdf/">Download the C# IronPDF library to delay PDF rendering</a></li>
<li>Generate a PDF document from an HTML string, file, or web URL</li>
<li>Use the JavaScript method of <code>WaitFor</code> to trigger the render from a JavaScript function</li>
<li>Delay the render based on the number of network activities</li>
<li>Wait for specific HTML elements as well as for all the fonts to be loaded</li>
</ol>
</div>
## What Is the `WaitFor` Class and Its Options?
For [rendering PDFs with optimal performance](/troubleshooting/ironpdf-performance-assistance/), the `WaitFor` class improves the PDF rendering process. The `WaitFor` object from `RenderOptions` offers several options:
- `PageLoad`: Default render with no waiting.
- `RenderDelay`: Sets an arbitrary waiting time.
- `Fonts`: Waits until all fonts have loaded.
- `JavaScript`: Triggers the render with a JavaScript function.
- `HTML elements`: Waits for specific HTML elements, such as element IDs, names, tag names, and query selectors to target elements.
- `NetworkIdle`: Waits for network idle (0, 2, or a custom amount).
These features work when converting [HTML strings to PDF with IronPDF](/how-to/html-string-to-pdf/), [HTML files to PDF with IronPDF](/how-to/html-file-to-pdf/), and [web URLs to PDF with IronPDF](/how-to/url-to-pdf/).
## How Do I Render PDFs Immediately Without Waiting?
By default, rendering occurs immediately after the page finishes loading. The `PageLoad` method doesn't need to be called for normal rendering. This approach works well for simple HTML content without complex JavaScript or external resources.
```cs
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render as soon as the page is loaded
renderer.RenderingOptions.WaitFor.PageLoad();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
```
## How Can I Add a Custom Delay Before PDF Rendering?
When a specific delay is required before rendering the PDF, you can set an arbitrary number of milliseconds as a delay. This provides flexibility for specific timing requirements, especially when dealing with [JavaScript-heavy content](https://ironpdf.com/how-to/javascript-to-pdf/).
This option works the same as the old implementation using the `RenderingOptions.RenderDelay` property. However, the old property has been deprecated. Use the new API: `RenderingOptions.WaitFor.RenderDelay`.
```cs
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render after 3000ms
renderer.RenderingOptions.WaitFor.RenderDelay(3000);
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
```
The delay mechanism is useful when your HTML contains animations, lazy-loaded content, or requires time for dynamic content generation. For complex rendering scenarios, explore [custom rendering options](https://ironpdf.com/how-to/rendering-options/).
## How Do I Wait for All Fonts to Load Before Rendering?
The `AllFontsLoaded` method in the `WaitFor` class pauses PDF rendering until all fonts load from external sources like Google Fonts. This ensures the final PDF includes all required fonts, preserving the document's intended typography and visual appearance. This feature maintains [professional PDF output quality](https://ironpdf.com/how-to/pixel-perfect-html-to-pdf/).
```cs
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<!-- for google web fonts -->
<link rel=""preconnect"" href=""https://fonts.googleapis.com"">
<link rel=""preconnect"" href=""https://fonts.gstatic.com"" crossorigin>
<link rel=""stylesheet"" href=""https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"" >
<style>
/* for remote fonts */
@font-face {
font-family: 'CustomFont';
src: url('https://stage.gradfinale.co.uk/tcpdf/fonts/avgr65wttf.ttf');
}
p#p1 { font-family: CustomFont, sans-serif; }
/* for local fonts */
@font-face {
font-family: 'LocalCustomFont';
src: local('Arial');
}
p#p3 { font-family: LocalCustomFont, sans-serif; }
</style>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<p style=""font-family: Roboto, monospace;"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p1"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p3"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
</body>
</html>)";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.AllFontsLoaded(10000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
```
For more information on managing fonts in PDFs, including embedding and subsetting options, check the guide on [managing fonts in PDFs](https://ironpdf.com/how-to/manage-fonts/).
## How Do I Trigger PDF Rendering Using Custom JavaScript?
For greater control over the rendering process, you can specify a custom JavaScript function that executes before rendering the PDF document. This enables you to perform necessary tasks or checks before initiating the rendering process, giving you control over when to trigger the render.
In JavaScript, the function `window.ironpdf.notifyRender()` triggers the rendering task. Once `notifyRender()` is invoked, the rendering process starts. You control when to invoke the function.
```js
using IronPdf;
string html = @"<!DOCTYPE html>
<html>
<body>
<h1>Testing</h1>
<script type='text/javascript'>
// Set delay
setTimeout(function() {
window.ironpdf.notifyRender();
}, 1000);
</script>
</body>
</html>";
ChromePdfRenderOptions renderingOptions = new ChromePdfRenderOptions();
// Set rendering to wait for the notifyRender function
renderingOptions.WaitFor.JavaScript(5000);
PdfDocument pdf = ChromePdfRenderer.StaticRenderHtmlAsPdf(html, renderingOptions);
```
This approach is effective when combined with AJAX requests or when ensuring dynamically generated content fully loads before rendering. For advanced JavaScript scenarios, see the guide on [executing custom JavaScript in PDFs](https://ironpdf.com/examples/execute-custom-javascript/).
## How Can I Wait for Specific HTML Elements Before Rendering?
With this option, the rendering process waits for specific HTML elements, such as element IDs, names, tag names, and query selectors to target elements. This feature helps when working with Single Page Applications (SPAs) or content that loads asynchronously.
### How Do I Wait for an Element by ID?
The rendering waits for a specific element ID in the code example below.
```cs
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
```
### How Do I Wait for an Element by Name Attribute?
The rendering process waits for a specific element name in the code example below.
```cs
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
```
### How Do I Wait for Elements by Tag Name?
The rendering process waits for a specific element tag name in the code example below.
```cs
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var newElem = document.createElement(""h2"");
newElem.innerHTML = ""bla bla bla"";
var block = document.querySelector(""div#x"");
block.appendChild(newElem);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementByTagName("h2", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
```
### How Do I Use Query Selectors to Wait for Elements?
The rendering process waits for the element selected by the query selector in the code example below. The `HtmlQuerySelector` method waits for an `img tag` with an `id of 'myid'` and a `class of 'blablastyle'`.
```cs
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<script type=""text/javascript"">
setTimeout(function() {
var img = document.createElement(""img"");
img.onload = function() {
img.setAttribute(""id"", ""myid"");
img.setAttribute(""class"", ""blablastyle"");
var block = document.getElementById(""x"");
block.appendChild(img);
};
img.src = ""https://www.w3schools.com/images/picture.jpg""; // .src after .onload to ignore cached, if any
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlQuerySelector("img#myid.blablastyle", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
```
## How Do I Wait for Network Activity to Complete?
When rendering web pages that make network requests for resources, data, or API calls, ensure all network activity completes before generating the PDF. IronPDF provides several methods to handle different network scenarios.
### When Should I Wait for Zero Network Activity?
This type of network idle waits until there is no network activity, typically indicating that content has fully loaded. This suits Single-Page Applications (SPAs) or simple web pages without long-polling network requests or ongoing network activity.
The rendering process commences once there has been **no ongoing** network activity for **at least 500ms**.
```cs
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there has been no network activity for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle0();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
```
### When Should I Allow Two Network Activities?
The `NetworkIdle2` method suits web applications or web pages with long-polling network requests or heartbeat pings. Typically, 1-2 requests are involved. Even if these requests are ongoing, they won't invalidate the triggering of the network idle event, as having at most two is acceptable.
Before initiating the rendering process, there should be **at most two** network activities remaining for **at least 500ms**. This option provides quick configuration for handling a fixed number of network activities.
```cs
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there are at most 2 network activities for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle2();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
```
### How Do I Customize Network Activity Thresholds?
When multiple network requests are involved, you can customize both the **network idle duration** and **the number of allowed network** requests that don't invalidate the network idle event. This option suits web applications or web pages with specific requirements that don't fit the previous two methods. This customization addresses a wide range of use cases under different circumstances.
```cs
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there are at most 5 network activities for at least 1000ms
renderer.RenderingOptions.WaitFor.NetworkIdle(1000, 5);
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
```
This level of customization is valuable when working with complex web applications that maintain persistent connections or have predictable background network activity patterns.
## How Do I Set a Maximum Waiting Time?
The `JavaScript`, `NetworkIdle`, `NetworkIdle0`, and `NetworkIdle2` methods allow you to set a maximum waiting time to ensure the wait won't be indefinite. The `maxWaitTime` parameter of these methods serves this purpose. This prevents your application from hanging indefinitely if the expected conditions never occur.
All specified time values are in milliseconds.
When implementing these waiting strategies, balance ensuring complete content loading with maintaining reasonable performance. For applications requiring precise timing control, explore [async PDF generation techniques](https://ironpdf.com/how-to/async/).
Ready to see what else you can do? Check the tutorial page here: [Additional Features](https://ironpdf.com/tutorials/pdf-assets-and-performance-csharp/) or explore [creating PDFs with IronPDF](https://ironpdf.com/how-to/create-new-pdfs/) for more advanced techniques.
The C# WaitFor class in IronPDF helps developers delay PDF rendering until all assets, fonts, and JavaScript have loaded, preventing incomplete renders by using methods like RenderDelay, NetworkIdle, and JavaScript triggers.
Quickstart: Using WaitFor to Improve PDF Rendering
IronPDF's WaitFor feature allows developers to improve PDF rendering by managing asynchronous timing. By setting options like RenderDelay, you can ensure all assets and scripts are loaded before the conversion, preventing incomplete PDF documents. This guide shows how to implement WaitFor in your projects for precise and efficient rendering.
ImportsIronPdfDim renderer As New ChromePdfRendererWith { .RenderingOptions = New ChromePdfRenderOptionsWith { .WaitFor = WaitFor.RenderDelay(3000) }}renderer.RenderUrlAsPdf("https://example.com").SaveAs("output.pdf")
Imports IronPdf
Dim renderer As New ChromePdfRenderer With {
.RenderingOptions = New ChromePdfRenderOptions With {
.WaitFor = WaitFor.RenderDelay(3000)
}
}
renderer.RenderUrlAsPdf("https://example.com").SaveAs("output.pdf")
Generate a PDF document from an HTML string, file, or web URL
Use the JavaScript method of WaitFor to trigger the render from a JavaScript function
Delay the render based on the number of network activities
Wait for specific HTML elements as well as for all the fonts to be loaded
What Is the WaitFor Class and Its Options?
For rendering PDFs with optimal performance, the WaitFor class improves the PDF rendering process. The WaitFor object from RenderOptions offers several options:
PageLoad: Default render with no waiting.
RenderDelay: Sets an arbitrary waiting time.
Fonts: Waits until all fonts have loaded.
JavaScript: Triggers the render with a JavaScript function.
HTML elements: Waits for specific HTML elements, such as element IDs, names, tag names, and query selectors to target elements.
NetworkIdle: Waits for network idle (0, 2, or a custom amount).
By default, rendering occurs immediately after the page finishes loading. The PageLoad method doesn't need to be called for normal rendering. This approach works well for simple HTML content without complex JavaScript or external resources.
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();// Render as soon as the page is loadedrenderer.RenderingOptions.WaitFor.PageLoad();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render as soon as the page is loaded
renderer.RenderingOptions.WaitFor.PageLoad();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
ImportsIronPdfDim renderer As New ChromePdfRenderer()' Render as soon as the page is loadedrenderer.RenderingOptions.WaitFor.PageLoad()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
' Render as soon as the page is loaded
renderer.RenderingOptions.WaitFor.PageLoad()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
How Can I Add a Custom Delay Before PDF Rendering?
When a specific delay is required before rendering the PDF, you can set an arbitrary number of milliseconds as a delay. This provides flexibility for specific timing requirements, especially when dealing with JavaScript-heavy content.
This option works the same as the old implementation using the RenderingOptions.RenderDelay property. However, the old property has been deprecated. Use the new API: RenderingOptions.WaitFor.RenderDelay.
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();// Render after 3000msrenderer.RenderingOptions.WaitFor.RenderDelay(3000);PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render after 3000ms
renderer.RenderingOptions.WaitFor.RenderDelay(3000);
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
ImportsIronPdfPrivate renderer As New ChromePdfRenderer()' Render after 3000msrenderer.RenderingOptions.WaitFor.RenderDelay(3000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
Imports IronPdf
Private renderer As New ChromePdfRenderer()
' Render after 3000ms
renderer.RenderingOptions.WaitFor.RenderDelay(3000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
The delay mechanism is useful when your HTML contains animations, lazy-loaded content, or requires time for dynamic content generation. For complex rendering scenarios, explore custom rendering options.
How Do I Wait for All Fonts to Load Before Rendering?
The AllFontsLoaded method in the WaitFor class pauses PDF rendering until all fonts load from external sources like Google Fonts. This ensures the final PDF includes all required fonts, preserving the document's intended typography and visual appearance. This feature maintains professional PDF output quality.
using IronPdf;string htmlContent = @"<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Test Registration of Extension</title> <!-- for google web fonts --> <link rel=""preconnect"" href=""https://fonts.googleapis.com""> <link rel=""preconnect"" href=""https://fonts.gstatic.com"" crossorigin> <link rel=""stylesheet"" href=""https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"" > <style> /* for remote fonts */ @font-face { font-family: 'CustomFont'; src: url('https://stage.gradfinale.co.uk/tcpdf/fonts/avgr65wttf.ttf'); } p#p1 { font-family: CustomFont, sans-serif; } /* for local fonts */ @font-face { font-family: 'LocalCustomFont'; src: local('Arial'); } p#p3 { font-family: LocalCustomFont, sans-serif; } </style></head><body> <h1>This is Delayed Render Test!</h1> <p style=""font-family: Roboto, monospace;"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p> <p id=""p1"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p> <p id=""p3"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p></body></html>)";ChromePdfRenderer renderer = new ChromePdfRenderer();renderer.RenderingOptions.WaitFor.AllFontsLoaded(10000);PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<!-- for google web fonts -->
<link rel=""preconnect"" href=""https://fonts.googleapis.com"">
<link rel=""preconnect"" href=""https://fonts.gstatic.com"" crossorigin>
<link rel=""stylesheet"" href=""https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"" >
<style>
/* for remote fonts */
@font-face {
font-family: 'CustomFont';
src: url('https://stage.gradfinale.co.uk/tcpdf/fonts/avgr65wttf.ttf');
}
p#p1 { font-family: CustomFont, sans-serif; }
/* for local fonts */
@font-face {
font-family: 'LocalCustomFont';
src: local('Arial');
}
p#p3 { font-family: LocalCustomFont, sans-serif; }
</style>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<p style=""font-family: Roboto, monospace;"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p1"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p3"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
</body>
</html>)";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.AllFontsLoaded(10000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
ImportsIronPdfDim htmlContent AsString = "<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Test Registration of Extension</title> <!-- for google web fonts --> <link rel=""preconnect"" href=""https://fonts.googleapis.com""> <link rel=""preconnect"" href=""https://fonts.gstatic.com"" crossorigin> <link rel=""stylesheet"" href=""https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"" > <style> /* for remote fonts */ @font-face { font-family: 'CustomFont'; src: url('https://stage.gradfinale.co.uk/tcpdf/fonts/avgr65wttf.ttf'); } p#p1 { font-family: CustomFont, sans-serif; } /* for local fonts */ @font-face { font-family: 'LocalCustomFont'; src: local('Arial'); } p#p3 { font-family: LocalCustomFont, sans-serif; } </style></head><body> <h1>This is Delayed Render Test!</h1> <p style=""font-family: Roboto, monospace;"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p> <p id=""p1"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p> <p id=""p3"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p></body></html>"Dim renderer As New ChromePdfRenderer()renderer.RenderingOptions.WaitFor.AllFontsLoaded(10000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
Imports IronPdf
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<!-- for google web fonts -->
<link rel=""preconnect"" href=""https://fonts.googleapis.com"">
<link rel=""preconnect"" href=""https://fonts.gstatic.com"" crossorigin>
<link rel=""stylesheet"" href=""https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"" >
<style>
/* for remote fonts */
@font-face {
font-family: 'CustomFont';
src: url('https://stage.gradfinale.co.uk/tcpdf/fonts/avgr65wttf.ttf');
}
p#p1 { font-family: CustomFont, sans-serif; }
/* for local fonts */
@font-face {
font-family: 'LocalCustomFont';
src: local('Arial');
}
p#p3 { font-family: LocalCustomFont, sans-serif; }
</style>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<p style=""font-family: Roboto, monospace;"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p1"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
<p id=""p3"">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla scelerisque ligula venenatis erat <strong>scelerisque</strong> auctor.</p>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.AllFontsLoaded(10000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
For more information on managing fonts in PDFs, including embedding and subsetting options, check the guide on managing fonts in PDFs.
How Do I Trigger PDF Rendering Using Custom JavaScript?
For greater control over the rendering process, you can specify a custom JavaScript function that executes before rendering the PDF document. This enables you to perform necessary tasks or checks before initiating the rendering process, giving you control over when to trigger the render.
In JavaScript, the function window.ironpdf.notifyRender() triggers the rendering task. Once notifyRender() is invoked, the rendering process starts. You control when to invoke the function.
usingIronPdf;string html = @"<!DOCTYPE html><html><body><h1>Testing</h1><script type='text/javascript'>// Set delaysetTimeout(function() { window.ironpdf.notifyRender();}, 1000);</script></body></html>";ChromePdfRenderOptions renderingOptions = new ChromePdfRenderOptions();// Set rendering to wait for the notifyRender functionrenderingOptions.WaitFor.JavaScript(5000);PdfDocument pdf = ChromePdfRenderer.StaticRenderHtmlAsPdf(html, renderingOptions);
using IronPdf;
string html = @"<!DOCTYPE html>
<html>
<body>
<h1>Testing</h1>
<script type='text/javascript'>
// Set delay
setTimeout(function() {
window.ironpdf.notifyRender();
}, 1000);
</script>
</body>
</html>";
ChromePdfRenderOptions renderingOptions = new ChromePdfRenderOptions();
// Set rendering to wait for the notifyRender function
renderingOptions.WaitFor.JavaScript(5000);
PdfDocument pdf = ChromePdfRenderer.StaticRenderHtmlAsPdf(html, renderingOptions);
JavaScript
This approach is effective when combined with AJAX requests or when ensuring dynamically generated content fully loads before rendering. For advanced JavaScript scenarios, see the guide on executing custom JavaScript in PDFs.
How Can I Wait for Specific HTML Elements Before Rendering?
With this option, the rendering process waits for specific HTML elements, such as element IDs, names, tag names, and query selectors to target elements. This feature helps when working with Single Page Applications (SPAs) or content that loads asynchronously.
How Do I Wait for an Element by ID?
The rendering waits for a specific element ID in the code example below.
using IronPdf;string htmlContent = @"<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var h1Tag = document.createElement(""h1""); h1Tag.innerHTML = ""bla bla bla""; h1Tag.setAttribute(""id"", ""myid""); var block = document.querySelector(""div#x""); block.appendChild(h1Tag); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>";ChromePdfRenderer renderer = new ChromePdfRenderer();renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
ImportsIronPdfDim htmlContent AsString = "<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var h1Tag = document.createElement(""h1""); h1Tag.innerHTML = ""bla bla bla""; h1Tag.setAttribute(""id"", ""myid""); var block = document.querySelector(""div#x""); block.appendChild(h1Tag); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>"Dim renderer As New ChromePdfRenderer()renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
Imports IronPdf
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
How Do I Wait for an Element by Name Attribute?
The rendering process waits for a specific element name in the code example below.
using IronPdf;string htmlContent = @"<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var h1Tag = document.createElement(""h1""); h1Tag.innerHTML = ""bla bla bla""; h1Tag.setAttribute(""id"", ""myid""); var block = document.querySelector(""div#x""); block.appendChild(h1Tag); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>";ChromePdfRenderer renderer = new ChromePdfRenderer();renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
ImportsIronPdfDim htmlContent AsString = "<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var h1Tag = document.createElement(""h1""); h1Tag.innerHTML = ""bla bla bla""; h1Tag.setAttribute(""id"", ""myid""); var block = document.querySelector(""div#x""); block.appendChild(h1Tag); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>"Dim renderer As New ChromePdfRenderer()renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
Imports IronPdf
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var h1Tag = document.createElement(""h1"");
h1Tag.innerHTML = ""bla bla bla"";
h1Tag.setAttribute(""id"", ""myid"");
var block = document.querySelector(""div#x"");
block.appendChild(h1Tag);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.HtmlElementById("myid", 5000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
How Do I Wait for Elements by Tag Name?
The rendering process waits for a specific element tag name in the code example below.
using IronPdf;string htmlContent = @"<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var newElem = document.createElement(""h2""); newElem.innerHTML = ""bla bla bla""; var block = document.querySelector(""div#x""); block.appendChild(newElem); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>";ChromePdfRenderer renderer = new ChromePdfRenderer();renderer.RenderingOptions.WaitFor.HtmlElementByTagName("h2", 5000);PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var newElem = document.createElement(""h2"");
newElem.innerHTML = ""bla bla bla"";
var block = document.querySelector(""div#x"");
block.appendChild(newElem);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlElementByTagName("h2", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
ImportsIronPdfDim htmlContent AsString = "<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Delayed render tests</title> <script type=""text/javascript""> setTimeout(function() { var newElem = document.createElement(""h2""); newElem.innerHTML = ""bla bla bla""; var block = document.querySelector(""div#x""); block.appendChild(newElem); }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>"Dim renderer As New ChromePdfRenderer()renderer.RenderingOptions.WaitFor.HtmlElementByTagName("h2", 5000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
Imports IronPdf
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Delayed render tests</title>
<script type=""text/javascript"">
setTimeout(function() {
var newElem = document.createElement(""h2"");
newElem.innerHTML = ""bla bla bla"";
var block = document.querySelector(""div#x"");
block.appendChild(newElem);
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.HtmlElementByTagName("h2", 5000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
How Do I Use Query Selectors to Wait for Elements?
The rendering process waits for the element selected by the query selector in the code example below. The HtmlQuerySelector method waits for an img tag with an id of 'myid' and a class of 'blablastyle'.
using IronPdf;string htmlContent = @"<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Test Registration of Extension</title> <script type=""text/javascript""> setTimeout(function() { var img = document.createElement(""img""); img.onload = function() { img.setAttribute(""id"", ""myid""); img.setAttribute(""class"", ""blablastyle""); var block = document.getElementById(""x""); block.appendChild(img); }; img.src = ""https://www.w3schools.com/images/picture.jpg""; // .src after .onload to ignore cached, if any }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>";ChromePdfRenderer renderer = new ChromePdfRenderer();renderer.RenderingOptions.WaitFor.HtmlQuerySelector("img#myid.blablastyle", 5000);PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
using IronPdf;
string htmlContent = @"
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<script type=""text/javascript"">
setTimeout(function() {
var img = document.createElement(""img"");
img.onload = function() {
img.setAttribute(""id"", ""myid"");
img.setAttribute(""class"", ""blablastyle"");
var block = document.getElementById(""x"");
block.appendChild(img);
};
img.src = ""https://www.w3schools.com/images/picture.jpg""; // .src after .onload to ignore cached, if any
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>";
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.HtmlQuerySelector("img#myid.blablastyle", 5000);
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
ImportsIronPdfDim htmlContent AsString = "<!DOCTYPE html><html lang=""en""><head> <meta charset=""UTF-8""> <title>Test Registration of Extension</title> <script type=""text/javascript""> setTimeout(function() { var img = document.createElement(""img""); img.onload = function() { img.setAttribute(""id"", ""myid""); img.setAttribute(""class"", ""blablastyle""); var block = document.getElementById(""x""); block.appendChild(img); }; img.src = ""https://www.w3schools.com/images/picture.jpg""; // .src after .onload to ignore cached, if any }, 1000); </script></head><body> <h1>This is Delayed Render Test!</h1> <div id=""x""></div></body></html>"Dim renderer As New ChromePdfRenderer()renderer.RenderingOptions.WaitFor.HtmlQuerySelector("img#myid.blablastyle", 5000)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
Imports IronPdf
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<title>Test Registration of Extension</title>
<script type=""text/javascript"">
setTimeout(function() {
var img = document.createElement(""img"");
img.onload = function() {
img.setAttribute(""id"", ""myid"");
img.setAttribute(""class"", ""blablastyle"");
var block = document.getElementById(""x"");
block.appendChild(img);
};
img.src = ""https://www.w3schools.com/images/picture.jpg""; // .src after .onload to ignore cached, if any
}, 1000);
</script>
</head>
<body>
<h1>This is Delayed Render Test!</h1>
<div id=""x""></div>
</body>
</html>"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.HtmlQuerySelector("img#myid.blablastyle", 5000)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(htmlContent)
My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.
IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.
When rendering web pages that make network requests for resources, data, or API calls, ensure all network activity completes before generating the PDF. IronPDF provides several methods to handle different network scenarios.
When Should I Wait for Zero Network Activity?
This type of network idle waits until there is no network activity, typically indicating that content has fully loaded. This suits Single-Page Applications (SPAs) or simple web pages without long-polling network requests or ongoing network activity.
The rendering process commences once there has been no ongoing network activity for at least 500ms.
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();// Render unless there has been no network activity for at least 500msrenderer.RenderingOptions.WaitFor.NetworkIdle0();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there has been no network activity for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle0();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
ImportsIronPdfDim renderer As New ChromePdfRenderer()' Render unless there has been no network activity for at least 500msrenderer.RenderingOptions.WaitFor.NetworkIdle0()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
' Render unless there has been no network activity for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle0()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
When Should I Allow Two Network Activities?
The NetworkIdle2 method suits web applications or web pages with long-polling network requests or heartbeat pings. Typically, 1-2 requests are involved. Even if these requests are ongoing, they won't invalidate the triggering of the network idle event, as having at most two is acceptable.
Before initiating the rendering process, there should be at most two network activities remaining for at least 500ms. This option provides quick configuration for handling a fixed number of network activities.
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();// Render unless there are at most 2 network activities for at least 500msrenderer.RenderingOptions.WaitFor.NetworkIdle2();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there are at most 2 network activities for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle2();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
ImportsIronPdfDim renderer As New ChromePdfRenderer()' Render unless there are at most 2 network activities for at least 500msrenderer.RenderingOptions.WaitFor.NetworkIdle2()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
' Render unless there are at most 2 network activities for at least 500ms
renderer.RenderingOptions.WaitFor.NetworkIdle2()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
How Do I Customize Network Activity Thresholds?
When multiple network requests are involved, you can customize both the network idle duration and the number of allowed network requests that don't invalidate the network idle event. This option suits web applications or web pages with specific requirements that don't fit the previous two methods. This customization addresses a wide range of use cases under different circumstances.
using IronPdf;ChromePdfRenderer renderer = new ChromePdfRenderer();// Render unless there are at most 5 network activities for at least 1000msrenderer.RenderingOptions.WaitFor.NetworkIdle(1000, 5);PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render unless there are at most 5 network activities for at least 1000ms
renderer.RenderingOptions.WaitFor.NetworkIdle(1000, 5);
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
ImportsIronPdfPrivate renderer As New ChromePdfRenderer()' Render unless there are at most 5 network activities for at least 1000msrenderer.RenderingOptions.WaitFor.NetworkIdle(1000, 5)Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
Imports IronPdf
Private renderer As New ChromePdfRenderer()
' Render unless there are at most 5 network activities for at least 1000ms
renderer.RenderingOptions.WaitFor.NetworkIdle(1000, 5)
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
This level of customization is valuable when working with complex web applications that maintain persistent connections or have predictable background network activity patterns.
How Do I Set a Maximum Waiting Time?
The JavaScript, NetworkIdle, NetworkIdle0, and NetworkIdle2 methods allow you to set a maximum waiting time to ensure the wait won't be indefinite. The maxWaitTime parameter of these methods serves this purpose. This prevents your application from hanging indefinitely if the expected conditions never occur.
All specified time values are in milliseconds.
When implementing these waiting strategies, balance ensuring complete content loading with maintaining reasonable performance. For applications requiring precise timing control, explore async PDF generation techniques.
What is the purpose of the C# `WaitFor` class in IronPDF?
The C# `WaitFor` class in IronPDF is used to delay PDF rendering until all assets, such as fonts and JavaScript, are fully loaded. This prevents incomplete PDF renders by using options like `RenderDelay`, `NetworkIdle`, and JavaScript triggers.
How does `RenderDelay` improve PDF rendering in IronPDF?
`RenderDelay` in IronPDF allows you to set a specific delay time before starting the PDF rendering process. This ensures all necessary assets are loaded, which is particularly useful for content that includes animations or dynamically loaded elements.
Can I trigger PDF rendering using JavaScript with IronPDF?
Yes, you can control the rendering process with a custom JavaScript function in IronPDF. By invoking `window.ironpdf.notifyRender()`, you trigger the PDF rendering when all your criteria are met, allowing for precise timing control.
How can IronPDF ensure all fonts load before rendering a PDF?
IronPDF provides an `AllFontsLoaded` method in the `WaitFor` class that pauses PDF rendering until all fonts are fully loaded. This is crucial for maintaining the intended typography and visual appearance in the final PDF output.
What network activity options does IronPDF offer for PDF rendering?
IronPDF offers options like `NetworkIdle0`, `NetworkIdle2`, and custom thresholds to wait for network activity to settle. These options ensure all network requests complete before rendering, which is crucial for web pages that fetch external data.
How do I wait for specific HTML elements before rendering in IronPDF?
IronPDF's `WaitFor` feature allows you to wait for specific HTML elements by ID, name, tag name, or query selectors. This is useful for rendering SPAs or asynchronously loaded content, ensuring all necessary elements are present before rendering.
How can I set a maximum waiting time for rendering a PDF in IronPDF?
You can set a maximum waiting time when using methods like `JavaScript`, `NetworkIdle`, `NetworkIdle0`, and `NetworkIdle2` in IronPDF. This prevents indefinite waiting by specifying a maximum duration to wait for conditions to be met.
Is it possible to customize network activity thresholds in IronPDF?
Yes, IronPDF allows you to customize the number of allowable network activities and the duration before considering the network idle. This flexibility is particularly useful for handling complex web applications with persistent network connections.
What happens when using the default `PageLoad` method in IronPDF?
The `PageLoad` method in IronPDF initiates rendering immediately after the HTML page finishes loading, without any delays. This approach is best for simple HTML content without additional asynchronous resources.
How does IronPDF handle PDF rendering for JavaScript-heavy content?
For JavaScript-heavy content, IronPDF allows setting explicit delays and waiting for specific JavaScript events to ensure all scripts and dynamic elements are fully processed and available before rendering the PDF.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.