ARTICLE AD BOX
I ran into this issue before , the map canvas often renders empty in headless Chromium because the map library (Leaflet/Mapbox/Google Maps) finishes drawing after the page’s initial load event. What worked for me was waiting for the map tiles/canvas to fully render before calling Page.PdfAsync(). You can try await page.WaitForFunctionAsync("document.querySelector('canvas')?.width > 0") or add a small delay after the map finishes initializing. Also make sure headless: true isn’t blocking WebGL (some maps need it). Once I waited for the canvas to be fully drawn, the map rendered correctly in the PDF.
New contributor
Oliver Benette is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
