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 creating PDFs in your Nuxt 3 application!

Application side

You can export Vue components to HTML through our composables. You can learn more about using nuxt-pdf in the application side here.

// file: ~/components/PDF.vue<script setup lang="ts">const pdfSection = ref<HTMLElement | null>(null)</script><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>

Server side

Or use our server side code based approch to define your design! You can learn more about using nuxt-pdf on the server side here.

// file: ~/server/api/pdf/my-pdf.vueimport { createPDF, streamReturnPDF } from '#pdf'export default eventHandler(async (event) => {  const pdf = createPDF()  pdf.text('Welcome to NuxtPDF!')  pdf.end()  return streamReturnPDF(event, pdf)})