API Reference
Import the public component, composable and CSS:
The v1.3.0 fonts, autoOptimize, svgMode and watermark design APIs are covered in the media and typography guide and watermark guide. For an earlier installation, use its versioned full reference.
import { Html2Pdf, useHtml2Pdf } from 'vue-pdf-export'
import 'vue-pdf-export/style.css'
Component props
| Area | Props | Details |
|---|---|---|
| Output | enableDownload (true), previewModal (false), filename (timestamp fallback) | Preview/download |
| Renderer | renderMode ('canvas'), pdfQuality (2), pdfFormat ('a4'), pdfOrientation ('portrait'), pdfContentWidth ('800px') | Rendering modes, paper formats |
| Layout | showLayout (false), floatLayout (false) | Component |
| Pagination | manualPagination (false), optional paginateElementsByHeight, paginationDebug (false) | Smart pagination |
| Layers | header?: HeaderOptions, footer?: FooterOptions, watermark?: WatermarkOptions | Headers, footers, watermarks |
| Composition | composition?: PdfCompositionOptions, pdfTemplate?, templatePosition? | Composition |
| Styling | styling, pageBackground, bodyBackground, pageClass, bodyClass, pageStyle, bodyStyle | PDF styling |
| Document | security, metadata, compress, htmlToPdfOptions | Security, metadata, core props |
| UI / telemetry | showLoader (true), loaderText, collectMetrics (false) | Events and slots |
The original direct injectHeader, header-*, injectFooter, footer-*, footerMode, and useFooterComponent props remain accepted. An explicitly set object field takes priority over its matching direct prop; omitted object fields fall back to direct props. See the compatibility guidance and mapping, or the earlier v1 headers and footers guides.
Methods and output
generatePdf({ composition? }?) returns Promise<Blob>. generatePdfArrayBuffer() returns Promise<ArrayBuffer>. generatePdfBase64({ dataUrl? }?) returns raw Base64 or a PDF data URL. print(), closePreview(), resetPagination(), and cancelGeneration() control the browser flow. See programmatic API. Exported helpers include pdfBlobToArrayBuffer, pdfBlobToBase64, serializePdfOutput, normalizePdfFilename, createPdfOptions, resolvePdfPages, paginateElement and resetPagination.
Events and slots
| Event | Payload |
|---|---|
progress, progressStage, generationComplete | Number, PdfProgressState, PdfGenerationCompletePayload |
startPagination, hasPaginated | No payload |
paginationBreak, paginationWarning, paginationComplete | PdfPaginationDiagnostic, same, PdfPaginationDiagnostic[]; debug mode only |
beforeDownload, hasDownloaded, closed, error | BeforeDownloadPayload, Blob, none, Error |
#pdf-content supplies body content; #loader supplies progress UI; #pdf-header and #pdf-footer receive pageNumber, totalPages, and orientation. See events and slots.
Public types
import type {
HeaderOptions, FooterOptions, PdfCompositionOptions, PdfTemplateSource,
PdfPaginationDiagnostic, PdfPaginationDiagnosticType, PdfPageTarget,
Html2PdfProps, Html2PdfOptions, PdfRenderMode, PdfFormat, PdfOrientation,
PdfBase64Options, PdfOutputFormat, PdfSerializedOutput, PdfSecurityOptions,
PdfMetadataOptions, WatermarkOptions, PdfProgressState,
} from 'vue-pdf-export'
The TypeScript guide lists the remaining public type exports. Internal slot resolvers and renderer staging details are not consumer-facing options.
