[solved] Contrib-pdfmake node - help please getting node to work

Using both examples exactly as provided in Node-Red - simple pdf and image svg pdf.

Both examples give the debug error "TypeError: URLBrowserResolver is not a constructor".

Thinking I must be doing something simple incorrectly ?

Have tried in two browsers Chrome 84.0.4147.89 & FireFox 79.0
Windows 10 64 bit environment
Node-Red v 1.1.2
Have "Googled" error and any other Node-Red flow examples without any joy

Any help or suggestions will be appreciated

I just tried it and hit the same issue. I would open up an issue on the node's GitHub page https://github.com/ollixx/node-red-contrib-pdfmake/issues

Thanks, have opened an issue on this node's GitHub page

I cloned the repo and changed the dependency in package.js for pdfmake to "0.1.65" - then installed like this...

npm install /my-local-github-clones/node-red-contrib-pdfmake

... and it works.

Looking at the pdfmake source, they added this URLBrowserResolver in v0.1.66

I am busy now raising an issue on their repo (will update this thread shortly)
Raised issue on pdfmake repo...

1 Like

If you want to get this working temporarily, a simple hack can be done until it is fixed...

  • Locate pdfmake.js in your .node-red folder (likely location is .node-red\node_modules\node-red-contrib-pdfmake\node_modules\pdfmake\build\pdfmake.js)

  • go to around line 21818 (search for var URLBrowserResolver =) then paste ABOVE that line, the following code...

    var isNode=new Function("try {return this===global;}catch(e){return false;}");
      var doc = printer.createPdfKitDocument(this.docDefinition, options);
      return doc;

    like this....

  • Save the file

  • restart node-red

Thank you for all the help with this item, very impressed with the turnaround and support.

Have updated to the new/current pdfmake v0.1.68 release and both supplied examples are working fine.

Since the underlying pdfmake lib was fixed, a simple install should now work. The developer of the node-red contrib node seems to be unresponsive (shame).

Thanks again.
Yes, normal install worked for me. Removed previous release and then reinstalled (both using Node-Red 'Manage palette')

1 Like

yes, so it seemed indeed.
Unfortunately I did not receive notifications from github before the posts from Steve-Mcl and until now were not registered here (shame?).
I have updated the node to use pdfmake v0.1.68 and it should all be fine now with node-red-contrib-pdfmake v1.0.3.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.