While generating PDF using puppeteer sharp, the content under canvas tag for map is not displaying, instead displaying empty [closed]

1 week ago 12
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.

Oliver Benette's user avatar

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.

Read Entire Article