Class WaitFor
A managed wrapper of wait-for configurations. It also provides factory methods to set all related configurations as per desire waitfor type.
Inheritance
Namespace: IronPdf.Engines.Chrome
Assembly: IronPdf.dll
Syntax
public class WaitFor : Object
Delaying the ChromePdfRenderer snapshot until a page's content is actually ready runs through WaitFor. It exposes 12 instance methods that configure when the renderer captures the page: after a fixed delay, after a network-idle threshold, after specific HTML elements appear, after fonts load, or after a JavaScript signal from the page. Application code reaches a configured WaitFor through ChromePdfRenderer.RenderingOptions.WaitFor.
Modern HTML pages frequently delay their final content past the initial DOM load. Scripts mutate the DOM after AJAX responses, web fonts arrive after the first paint, charts and dashboards render in stages, and lazy-loaded media settle later still. Without a wait-for configuration the renderer captures the snapshot too early and the PDF shows a partial page. The class is the dial that aligns the snapshot moment with the actual content-ready moment for the page being rendered.
Call one of the 12 methods on RenderingOptions.WaitFor to configure the next render call. The methods are mutating and each call replaces the prior configuration. RenderDelay(int delay) waits a fixed number of milliseconds. NetworkIdle0(), NetworkIdle2(), and NetworkIdle(...) wait until network activity drops below a threshold (strict, relaxed, or custom). JavaScript(int maxWaitTime = 10000) pauses the snapshot until page JavaScript calls window.ironpdf.notifyRender(), giving the page itself control over the render moment. HtmlElementById, HtmlElementByClassName, HtmlElementByName, HtmlElementByTagName, and HtmlQuerySelector wait until a matching element appears in the DOM. AllFontsLoaded waits for web fonts to load. PageLoad() is the default and resets configuration so the renderer captures immediately after DOM ready. Every method except PageLoad and RenderDelay accepts an optional maxWaitTime argument (milliseconds) that caps the total wait. The WaitFor how-to guide walks through each option with worked examples.
using IronPdf;
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = true;
// Wait for a JavaScript signal from the page. Page-side scripts call
// window.ironpdf.notifyRender() when their async work is complete; the
// renderer then captures the snapshot. maxWaitTime caps the wait at 15s.
renderer.RenderingOptions.WaitFor.JavaScript(maxWaitTime: 15000);
// Alternative patterns (each call replaces the prior WaitFor configuration):
// renderer.RenderingOptions.WaitFor.RenderDelay(3000);
// renderer.RenderingOptions.WaitFor.NetworkIdle0(maxWaitTime: 10000);
// renderer.RenderingOptions.WaitFor.HtmlQuerySelector("#chart.rendered");
// renderer.RenderingOptions.WaitFor.AllFontsLoaded();
// renderer.RenderingOptions.WaitFor.PageLoad(); // reset to default
PdfDocument pdf = renderer.RenderUrlAsPdf(new Uri("https://example.com/dashboard"));
pdf.SaveAs("dashboard.pdf");For pages that drive their own render moment from JavaScript, the JavaScript to PDF how-to covers the window.ironpdf.notifyRender() signal pattern in depth. The rendering options how-to places WaitFor in the broader context of ChromePdfRenderOptions and its companion settings.
Methods
AllFontsLoaded(Int32)
This method proceeds rendering by waiting until all of its fonts have been loaded. Such font types can local, remote, or google web fonts.
Declaration
public void AllFontsLoaded(int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | maxWaitTime | maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
HtmlElementByClassName(String, Int32)
This method proceeds rendering by waiting until it finds the HTML element whose the class name as of the specified one.
Related JavaScript API that works similarly to this method is getElementsByClassName() but effective only for first found element from the result. Instead it makes a query directly via
document.querySelector() as it calls HtmlQuerySelector(String, Int32) internally.
Declaration
public void HtmlElementByClassName(string classAttribName, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | classAttribName | Target element's class attribute name. Class attribute name token must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), and underscores ("_"). |
| System.Int32 | maxWaitTime | Maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
Exceptions
| Type | Condition |
|---|---|
| IronPdfInputException | Thrown if input name is invalid not according to HTML name and Id naming rule. |
HtmlElementById(String, Int32)
This method proceeds rendering by waiting until it finds the HTML element that has the same id as specified one.
Related JavaScript API that works similarly to this method is getElementById() but instead it makes a query directly via
document.querySelector() as it calls HtmlQuerySelector(String, Int32) internally.
Declaration
public void HtmlElementById(string id, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | id | Target element Id. Id token must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). |
| System.Int32 | maxWaitTime | Maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
Exceptions
| Type | Condition |
|---|---|
| IronPdfInputException | Thrown if input id is invalid not according to HTML name and Id naming rule. |
HtmlElementByName(String, Int32)
This method proceeds rendering by waiting until it finds the element with the attribute name as of the specified one.
Related JavaScript API that works similarly to this method is getElementsByName() but effective only for first found element from the result. Instead it makes a query directly via
document.querySelector() as it calls HtmlQuerySelector(String, Int32) internally.
Declaration
public void HtmlElementByName(string name, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Target element name. Name token must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). |
| System.Int32 | maxWaitTime | Maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
Exceptions
| Type | Condition |
|---|---|
| IronPdfInputException | Thrown if input name is invalid not according to HTML name and Id naming rule. |
HtmlElementByTagName(String, Int32)
This method proceeds rendering by waiting until it finds the HTML element that itself has the same tag name as of specified one.
Related JavaScript API that works similarly to this method is getElementsByTagName() but effective only for first found element from the result. Instead it makes a query directly via
document.querySelector() as it calls HtmlQuerySelector(String, Int32) internally.
Declaration
public void HtmlElementByTagName(string tagName, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | tagName | Target element's tag name. Tag name token must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). |
| System.Int32 | maxWaitTime | Maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
Exceptions
| Type | Condition |
|---|---|
| IronPdfInputException | Thrown if input name is invalid not according to HTML name and Id naming rule. |
HtmlQuerySelector(String, Int32)
This method proceeds rendering by waiting until it finds the HTML element via the specified query string which is executed by a JavaScript function
document.querySelector().
Declaration
public void HtmlQuerySelector(string htmlQueryStr, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | htmlQueryStr | HTML element query string to query for with Javascript's document.querySelector() |
| System.Int32 | maxWaitTime | Maximum wait time (in ms) until it forces rendering. Default is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime. |
JavaScript(Int32)
This method proceeds rendering by waiting until user calls IronPdf's internal JavaScript function
window.ironpdf.notifyRender().
Declaration
public void JavaScript(int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | maxWaitTime | Maximum wait time in milliseconds until it forces rendering. Default value is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime |
NetworkIdle(Int32, Int32, Int32)
This method proceeds rendering by waiting until it internally detects a network idle event when there is no network activity after at least specified networkIdleDuration as well as at maximum of maxNumAllowedInflight inflight (outstanding) network requests.
Declaration
public void NetworkIdle(int networkIdleDuration, int maxNumAllowedInflight, int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | networkIdleDuration | Duration of time in milliseconds to regard as network idle event |
| System.Int32 | maxNumAllowedInflight | Maximum number of allowed inflight network requests to not invalidate network idle event |
| System.Int32 | maxWaitTime | Maximum wait time in milliseconds until it forces rendering. Default value is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime |
NetworkIdle0(Int32)
This method proceeds rendering by waiting until it internally detects a network idle event when there is no network activity. after at least 500ms as well as no inflight (outstanding) network requests.
Declaration
public void NetworkIdle0(int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | maxWaitTime | Maximum wait time in milliseconds until it forces rendering. Default value is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime |
NetworkIdle2(Int32)
This method proceeds rendering by waiting until it internally detects a network idle event when there is no network activity after at least 500ms as well as at maximum of 2 inflight (outstanding) network request.
Declaration
public void NetworkIdle2(int maxWaitTime = 10000)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | maxWaitTime | Maximum wait time in milliseconds until it forces rendering. Default value is IronPdf.Engines.Chrome.WaitFor.DefaultMaxWaitTime |
PageLoad()
Basically it waits for nothing, but will render as soon as the page loaded.
There is no need to call this method if user desires to normally render the page. It is mostly useful to reset WaitFor configurations back to wait for nothing.
Declaration
public void PageLoad()
RenderDelay(Int32)
This method proceeds rendering by introducing an initial delay before rendering.
Declaration
public void RenderDelay(int delay)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | delay | Delay time in milliseconds before rendering |