Skip to Content
Anuma SDKReactPdf ExportrenderElementToCanvas

renderElementToCanvas

renderElementToCanvas(element: HTMLElement, options?: Pick<PdfExportOptions, "onProgress">): Promise<HTMLCanvasElement>

Defined in: src/lib/pdf-export.ts:230 

Render a DOM element to a canvas using iframe isolation.

This is the first half of the DOM capture pipeline: it clones the element into an isolated iframe (to avoid affecting dark mode), copies stylesheets, and uses html2canvas to produce a high-fidelity snapshot. The returned canvas can be displayed as a preview before building the final PDF.

Parameters

ParameterType

element

HTMLElement

options?

Pick<PdfExportOptions, "onProgress">

Returns

Promise<HTMLCanvasElement>

Last updated on