Quick Start

After installing the package, add the package to your nuxt.config.ts:

export default defineNuxtConfig({   modules: ['@sidebase/nuxt-pdf'],})

That's it! You can now begin exporting Nuxt 3 components to PDF. For example:

<template>  <div>    <div ref="pdfSection">      Thanks for testing out nuxt-pdf!    </div>    <button @click="exportToPDF('my-pdf-file.pdf', pdfSection)">      print card    </button>  </div></template><script setup lang="ts">import { ref } from 'vue'import { exportToPDF } from '#imports'const pdfSection = ref<HTMLElement | null>(null)</script>

We offer two separate options parameters, that allow you to customize your pdf export.

  • The documentOptions, allow you to customize the general layout of your document. You can find the options here.
  • The options, allow you to customize the conversion of your HTML to a canvas. You can find the options here.