Blank Sections in PDFs from JavaScript-Rendered HTML
JavaScript-populated pages can render with blank sections or missing data in the PDF, even though the same HTML looks correct in a browser. IronPDF's Chromium renderer sometimes captures the page before the script output is fully applied, and print CSS media rules can hide or reflow content that displays fine on screen.
Switching CssMediaType to Screen makes the content appear, but the layout alignment breaks, so it is not a fix when print-accurate output is required.
The exact root cause was not definitively confirmed. The behavior is consistent with two factors combining:
- JavaScript timing: dynamic content is not fully rendered before the PDF snapshot is taken, leaving blank space where the data should be.
- Print CSS:
@media printrules hide or reflow content differently from screen CSS. WhenScreenshows the data butPrintdoes not, the missing content is a print-CSS effect rather than missing data.
In the case behind this article, the standard IronPdf package's Chrome engine did not render the page correctly even with JavaScript enabled and extended wait times. The newer engine in IronPdf.UpdatedChrome handled it.
Solution
1. Start with a JavaScript-aware rendering configuration
This is the required baseline for any JavaScript-populated page, though in the source case it was not sufficient on its own. Enable JavaScript, force print media, keep Chrome default rendering, print backgrounds, and give both the render and the JavaScript enough time to finish.
var renderer = new ChromePdfRenderer
{
RenderingOptions =
{
EnableJavaScript = true,
CssMediaType = PdfCssMediaType.Print
}
};
renderer.RenderingOptions.PaperFit.UseChromeDefaultRendering();
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.WaitFor.RenderDelay(10000);
renderer.RenderingOptions.WaitFor.JavaScript(10000);
using var pdf = renderer.RenderHtmlAsPdf(html);
var renderer = new ChromePdfRenderer
{
RenderingOptions =
{
EnableJavaScript = true,
CssMediaType = PdfCssMediaType.Print
}
};
renderer.RenderingOptions.PaperFit.UseChromeDefaultRendering();
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.WaitFor.RenderDelay(10000);
renderer.RenderingOptions.WaitFor.JavaScript(10000);
using var pdf = renderer.RenderHtmlAsPdf(html);
Imports System
Dim renderer As New ChromePdfRenderer With {
.RenderingOptions = New RenderingOptions With {
.EnableJavaScript = True,
.CssMediaType = PdfCssMediaType.Print
}
}
renderer.RenderingOptions.PaperFit.UseChromeDefaultRendering()
renderer.RenderingOptions.PrintHtmlBackgrounds = True
renderer.RenderingOptions.WaitFor.RenderDelay(10000)
renderer.RenderingOptions.WaitFor.JavaScript(10000)
Using pdf = renderer.RenderHtmlAsPdf(html)
' Use pdf as needed
End Using
The WaitFor.RenderDelay and WaitFor.JavaScript calls give the page ten seconds each to settle before the snapshot. See the WaitFor how-to for details.
2. Switch to the updated Chrome engine
Recommended: if content is still blank with the configuration above, move to the updated Chrome rendering engine. Uninstall the standard package and install the updated one.
dotnet remove package IronPdf
dotnet add package IronPdf.UpdatedChrome
dotnet remove package IronPdf
dotnet add package IronPdf.UpdatedChrome
IronPdf.UpdatedChrome is designed as a drop-in replacement for IronPdf with a newer Chrome engine. The ticket behind this article was resolved after this change.
3. Confirm whether print CSS is involved
Render the same HTML twice, once with PdfCssMediaType.Print and once with PdfCssMediaType.Screen, then compare. If Screen shows the data but Print does not, the page's @media print rules are hiding or reflowing the content, and the print stylesheet should be reviewed.
4. Reproduce in a minimal console app
When the problem persists, reproduce it in a minimal console application using the final rendered HTML. This isolates whether the issue is application-specific or renderer-specific, and gives support a reproducible sample.
What Doesn't Work
- Rendering config alone on the standard package: JavaScript enabled,
Printmedia type, and ten-second render and JavaScript waits did not restore the missing content in this case without the updated engine. - Switching
CssMediaTypetoScreen: the missing content appears, but the layout is no longer aligned correctly, so it fails when print-accurate output is required.

