How to generate or save PDF in LWC?

April 13, 2022
2 min read
By Salman bin Abu Hassan

telcowindevs

If you want to contribute to this project and help us to improve it, your help is most welcome. You can either contribute by writing a blog post, code snippets, or even fix a simple typo. You can do so by following the instructions below.

Steps

  • Add static resource of latest jsPDF library library to enable for its usage. Save the page as js extension and add it to the static resource of your org. You can do it by adding it through the the org interface or drag the file to the static resource of your org in VS Code.
  • Create a Lightning Web Component in your project. It is up to you to make it as a quick action, normal button or etc.
  • Refer to the snippets of jsPDF: Generate or save PDF in LWC for example

Note: This code could be improved for better user experience. Feel free to add or edit the code. Eg: Preview generated PDF in new window

Contributors

  • Salman Abu Hassan