Skip to footer content
USING IRONPDF

Capturing WebGL Maps and 3D Visualizations as PDFs in C#

Interactive maps, 3D dashboards, and model viewers built with WebGL look great in a browser, but stakeholders often need a fixed, shareable version: a map snapshot in a report, a 3D design in an approval packet, a simulation result in an archive. IronPDF captures GPU-accelerated WebGL content as a static PDF in C#, preserving the visual state of the scene at the moment it renders.

The Business Problem

A logistics tool shows routes on a Mapbox map, a real estate app displays 3D terrain, an engineering app renders a CAD model in the browser. Each needs a PDF version for a report, a record, or a recipient who does not have access to the live application. A normal screenshot is low quality and manual, and standard HTML-to-PDF rendering does not capture WebGL, which depends on the GPU.

Configuring the Render

WebGL capture needs three settings: single-process mode, hardware GPU mode, and a delay so the scene finishes rendering before capture.

using IronPdf;

// Required for WebGL: GPU operations must complete in one process
IronPdf.Installation.SingleProcess = true;
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Hardware;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Give the 3D scene time to load and render
renderer.RenderingOptions.WaitFor.RenderDelay(5000);

PdfDocument pdf = renderer.RenderUrlAsPdf("https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-slot/");
pdf.SaveAs("webgl.pdf");
using IronPdf;

// Required for WebGL: GPU operations must complete in one process
IronPdf.Installation.SingleProcess = true;
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Hardware;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Give the 3D scene time to load and render
renderer.RenderingOptions.WaitFor.RenderDelay(5000);

PdfDocument pdf = renderer.RenderUrlAsPdf("https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-slot/");
pdf.SaveAs("webgl.pdf");
Imports IronPdf

' Required for WebGL: GPU operations must complete in one process
IronPdf.Installation.SingleProcess = True
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Hardware

Dim renderer As New ChromePdfRenderer()

' Give the 3D scene time to load and render
renderer.RenderingOptions.WaitFor.RenderDelay(5000)

Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-slot/")
pdf.SaveAs("webgl.pdf")
$vbLabelText   $csharpLabel

The result captures the map, chart, or model exactly as it appeared, suitable for documentation, reports, and archival.

Points to Plan For

This feature carries real environment requirements, and they decide whether it fits a given deployment.

  • A real GPU is required: Hardware GPU mode is mandatory. Software rendering cannot handle shaders, textures, and 3D transforms, so the host needs a compatible GPU with current drivers.
  • Docker is not supported: WebGL rendering does not work in standard Docker containers, which are headless with limited GPU access. The workarounds are a VM or dedicated GPU-enabled server, a microservice running on a GPU host, or pre-rendering scenes to static images.
  • Output is a snapshot: The PDF preserves the visual state at render time. Panning, zooming, and other interactivity are not retained, which is why this suits documentation and archival rather than interactive delivery.
  • Tune the render delay: Complex scenes need time to load. Values between 3000 and 10000 milliseconds are a reasonable range to test against, since too short clips the render and too long wastes time.
  • Single-process mode is global: It is required here but affects concurrency, which is worth weighing in a high-volume service.

Result

With GPU mode enabled and a suitable host, teams turn live WebGL maps, dashboards, and 3D models into static PDFs that travel into reports and archives. Full configuration and troubleshooting steps are in the render WebGL guide.

Curtis Chau
Technical Writer

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.

...

Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me