sidebase/nuxt-pdf

`window is not defined` on SSR with Nuxt UI <UButton>

Opened this issue · 0 comments

Environment

- Operating System: Darwin
- Node Version:     v21.6.1
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  bun@1.1.6
- Builder:          -
- User Config:      devtools, modules, routeRules, i18n
- Runtime Modules:  @nuxt/ui@^2.15.2, @nuxt/fonts@^0.6.1, @nuxtjs/i18n@8.3.0, @sidebase/nuxt-pdf@^1.0.0-alpha.0
- Build Modules:    -

Reproduction

No response

Describe the bug

This works:

<button @click="exportToPDF('filename.pdf', pdfContent)">Create PDF</button>

This throws an error:

<UButton @click="exportToPDF('filename.pdf', pdfContent)">Create PDF</UButton>

On SSR it throws window is not defined from node_modules/jspdf/dist/jspdf.min.js:171:8032. When opening another page and then navigating to the page that contains the above code it works, e.g.:

  • /pdf -> error
  • /another-page -> /pdf -> works

Additional context

No response

Logs

No response

Btw. I wonder if this project is still maintained? According to #11 custom fonts dont work and pdf size is 8mb instead of 400kb.