I recently decided to use the PDF-lib library to generate some PDF in weweb.
Everything was working perfectly when testing my code using the test button inside of the workflow.
But when finally deciding to test the full workflow live on the form submit button, everything crumbled.
Explanation:
When calling the following:
const page = pdfDoc.addPage([600, 800]);
I will get this error:
“page must be of type n or PDFPage or Array, but was actually of type NaN”
What is so different about the the way javascript is run between when running using the test button, and running when actually clicking on the submit form button?
This is pretty critical, so I’d appreciate a quick response.
Hi Luka. Thank you for your response.
I got even better, I recorded a loom video of the issue.
You will see it’s very odd. Should there be any environment differences when running in test and when clicking on the submit button?
It’s failing on the last line and interprets [600, 800] as NaN
Again, as you can see the problem is not with the code. The problem is with weweb doing something different when the workflow is executing from the button click, and probably pointing to a different environment.
It would be great if you could tag in here someone who is experienced with your NPM integration, I think that this would help a lot.
Thanks a lot! I’ve already received a pretty valuable response there, and it unblocked me on the first part of the issue. I have another issue with embedFont, it does the same problem. I will try to use the prebuilt stuff of PDF-lib as much as possible.