How to Render WebGL Sites

by Chaknith Bin

WebGL is a powerful tool for creating interactive 3D graphics within web browsers, but converting these dynamic, highly interactive experiences into a static PDF format can be challenging. Rendering a WebGL website to PDF involves capturing the visual content generated by the WebGL context and converting it into a format suitable for a PDF document.

IronPDF provides the tools needed to capture and render websites with WebGL such as Mapbox and WebGL Samples collection .


C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer

Check out IronPDF on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming PDF with C#.

C# NuGet Library for PDF nuget.org/packages/IronPdf/
Install-Package IronPdf

Consider installing the IronPDF DLL directly. Download and manually install it for your project or GAC form: IronPdf.zip

Manually install into your project

Download DLL

Render WebGL Websites

To enable WebGL rendering, there are a few IronPDF settings you need to configure:

  • SingleProcess = true. This forces Chrome to perform everything in the current process rather than using subprocesses.
  • ChromeGpuMode = Hardware mode.

Additionally, if the website requires some delay before rendering to display properly, you may use the WaitFor.RenderDelay method. Let's render a sample from mapbox for our example.

:path=/static-assets/pdf/content-code-examples/how-to/render-webgl-render-webgl.cs
using IronPdf;

// Configure IronPdf settings
IronPdf.Installation.SingleProcess = true;
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Hardware;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Set delay before rendering
renderer.RenderingOptions.WaitFor.RenderDelay(5000);

// Render from URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-slot/");

pdf.SaveAs("webGL.pdf");
Imports IronPdf

' Configure IronPdf settings
IronPdf.Installation.SingleProcess = True
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Hardware

Dim renderer As New ChromePdfRenderer()

' Set delay before rendering
renderer.RenderingOptions.WaitFor.RenderDelay(5000)

' Render from URL
Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-slot/")

pdf.SaveAs("webGL.pdf")
VB   C#

Output PDF

It is currently not possible to render WebGL in a Docker setup. Rendering WebGL on Docker can be challenging because Docker containers are typically headless environments, meaning they do not have a graphical user interface (GUI). WebGL relies on access to the GPU to render graphics, and in a headless environment, access to the GPU is limited or nonexistent. Our developers are still investigating this possibility. If you want to be notified once a conclusion has been reached, please contact support@ironsoftware.com.

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.