API
Html2Pdf Component
The component owns the export DOM, generation state, preview/download flow, cancellation state and exposed methods. Use it directly when you want a template-first Vue API.
Core props
| Prop | Type | Default | Description |
|---|---|---|---|
renderMode | `'canvas' \ | 'text'` | 'canvas' |
showLayout | boolean | false | Show export layout. |
floatLayout | boolean | false | Use fixed/floating export layout. |
enableDownload | boolean | true | Download after generation. |
previewModal | boolean | false | Show PDF preview modal. |
filename | string | timestamp fallback | PDF filename. |
pdfQuality | number | 2 | Default html2canvas scale; mainly relevant to canvas mode/images. |
pdfFormat | PDF format | 'a4' | PDF format. |
pdfOrientation | `'portrait' \ | 'landscape'` | 'portrait' |
pdfContentWidth | string | '800px' | Export wrapper width. |
htmlToPdfOptions | Html2PdfOptions | package defaults | Advanced options. |
metadata | PdfMetadataOptions | undefined | PDF metadata. |
compress | boolean | undefined | jsPDF stream compression override. |
security | PdfSecurityOptions | undefined | Password/security configuration. |
manualPagination | boolean | false | Manual pagination mode. |
paginateElementsByHeight | number | undefined | Positive finite height enables smart DOM pagination; otherwise the renderer handles basic page flow. |
showLoader | boolean | true | Show loader. |
loaderText | string | 'Generating PDF...' | Loader text. |
watermark | WatermarkOptions | disabled | Watermark configuration. |
collectMetrics | boolean | false | Collect total/stage/per-page generation timing metrics. |
styling | PdfStylingOptions | disabled/defaults | Apply export-only page/body styling, scoped CSS, theme and auto-fit controls. |
Header and footer props are documented in their dedicated sections.
New props: header?: HeaderOptions, footer?: FooterOptions, composition?: PdfCompositionOptions, paginationDebug?: boolean, pdfTemplate?: PdfTemplateSource, and templatePosition?: 'prepend' | 'append' | 'both'. See headers, footers, composition, and pagination.
Version 1.3.0 also accepts fonts, autoOptimize and svgMode. See the media and typography guide.
Exposed methods
interface Html2PdfInstance {
generatePdf: (overrides?: { composition?: PdfCompositionOptions }) => Promise<Blob>
generatePdfArrayBuffer: () => Promise<ArrayBuffer>
generatePdfBase64: (options?: PdfBase64Options) => Promise<string>
print: () => Promise<void>
closePreview: () => void
resetPagination: () => void
cancelGeneration: () => void
}
generatePdfArrayBuffer() and generatePdfBase64() reuse the generated PDF Blob and do not run a second renderer.
See Programmatic API for output examples and cancellation details.
