NPM Library For PDF Creating

Hi!
Recently i’ve tried to add PDF creation functonality into my Weweb project. I’ve found a couple of npm libraries that can help me with that and installed them in NPM plugin. One of them was html2pdf.
When i’m trying to use it’s functions in workflow custom js action i can see that the functions are completely different than the ones that should actually be added with this plugin

image

They are always the same even with different libs (jspdf etc).

In the same time, libs from the test showcase video (papaparse, lodash) working completely fine and getting the right functions

I’ve noticed that in the case of working libs, weweb automatically gives them an instance name, but for broken ones it’s always empty.

I know that not all of npm libraries are currently work with weweb, but how can i get the list of working ones? Or maybe i should somehow configure the instance name?
Please help

Are you sure you got the right name of the library? html2pdf is a library from 9 years ago. There are many libraries with similar names, for example html2pdf.js.

1 Like

Hi!
All the libraries regarding pdf are working the same.

1 Like

How to add this html2pdf using the NPM plugin? When I tried this it was ‘empty’ trying to use it in custom JS.

Hello,

I seem to have the same issue while trying to add some NPM libraries. I tried to add pdf-lib using instance name “_” (not sure if this is right) and got this list of unrelated functions. (from the first post on the thread) I got the same with other libraries.

Maybe the issue is with the instance name - how do I find the right instance name for an NPM library that I add?

The NPM plugin in Weweb is quite rough-and-ready: it gives you an easier way to inject a specific subset of code hosted on unpkg.com. It takes a bit of shopping and investigation to get good value out of whichever package you decide to import. I made a video about getting started with this:

1 Like

The pdf-lib instance name is PDFLib I have used it to create a receipt .

1 Like

Thanks a lot @sam1 . This seems to work, let me try to use it.

2 Likes