简体   繁体   中英

How to Export a div to a formated PDF using NextJs

I have an app project on which we fill out forms and the information will be automatically formatted in a div to create labels (CLP labels) , so I would like to be able to export this Div in pdf format and can choose the sizes (landscape format from A5 to A8)

For this project I'm using Next.js and tailwind css.

And my question is : How to export a div in pdf format using NextJs ?

Thanks !

There are a few ways to do this

  1. An NPM Server side module - more options potentially
  2. Client side PDF object formation, lots of challenges - client side dependencies
  3. Use a service - cost

For #1 - try something like - https://www.npmjs.com/package/html-pdf?activeTab=readme

For #2 - https://github.com/parallax/jsPDF

For #3 - https://www.htmlpdfapi.com/

From my previous post on this - How can I export a Nextjs page as pdf?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM