API

PDF Styling & data-pdf-ignore

Customize export-only page and body styles, CSS classes, themes and auto-fit behavior, and exclude screen-only elements using data-pdf-ignore.

Exclude content from the PDF

Use data-pdf-ignore for controls, helper UI, debug panels, buttons, or any subtree that should stay visible in the application but not appear in the generated PDF.

<div>
  <h1>Invoice</h1>

  <button data-pdf-ignore>
    Edit invoice
  </button>

  <aside data-pdf-ignore="true">
    This entire subtree is excluded from the PDF.
  </aside>

  <p data-pdf-ignore="false">
    Explicit false keeps this content in the PDF.
  </p>
</div>
MarkupPDF behavior
data-pdf-ignoreexcluded
data-pdf-ignore="true"excluded
data-pdf-ignore="false"included

Ignored content is removed only from the temporary export copy and is also excluded from export pagination measurements.

Export-only styling

import type {
  PdfPageContext,
  PdfStyle,
  PdfStylingOptions,
} from 'vue-pdf-export'

const bodyStyle: PdfStyle = {
  padding: '16px',
  fontSize: '14px',
  color: '#17324A',
}

const styling: PdfStylingOptions = {
  enabled: true,

  pageBackground: '#FFF8E7',
  bodyBackground: '#F8FAFC',

  pageClass: 'invoice-page',
  bodyClass: 'invoice-body',

  pageStyle: ({ pageNumber }: PdfPageContext) => ({
    padding: '24px',
    border: '2px solid #DCE7E9',
    borderRadius: '12px',
    backgroundColor: pageNumber === 1 ? '#FFF7ED' : '#FFFFFF',
  }),

  bodyStyle,

  cssText: `
    .invoice-title {
      font-size: 28px;
      letter-spacing: -0.02em;
    }

    .screen-only {
      display: none;
    }
  `,

  printStylesheetUrls: [
    '/pdf/invoice-print.css',
  ],

  theme: 'light',

  autoFit: {
    enabled: true,
    minScale: 0.6,
    maxScale: 1,
    allowUpscale: false,
  },
}
<Html2Pdf :styling="styling">
  <template #pdf-content>
    <article>
      <h1 class="invoice-title">Invoice</h1>
      <button class="screen-only">Application action</button>
    </article>
  </template>
</Html2Pdf>

Styling options

OptionTypePurpose
enabledbooleanMaster styling switch.
pageBackgroundstringPDF page surface background.
bodyBackgroundstringInner body/content surface background.
pageClassstringExport-only page class names.
bodyClassstringExport-only body class names.
pageStyle`PdfStyle \PdfStyleResolver`
bodyStylePdfStyleStatic body styles.
cssTextstringExport-only scoped CSS text.
stylesheetUrlsstring[]External export stylesheet URLs.
printStylesheetUrlsstring[]External print/export stylesheet URLs.
theme`'current' \'light' \
autoFit`boolean \PdfAutoFitOptions`

Temporary export styles, themes, stylesheets, and staging DOM are cleaned up after generation.

Copyright © 2026