I've been working on a custom widget for a few weeks now and it has go !tten to the point in which i need to add "print to PDF" functionality. The widget in question generates a report in a modal found within the widget's own HTML file.
I looke online for solutions and i found this: jsPDF. It allows me to save a <div> element of the modal as a PDF to be saved and potentially printed in A4 paper. Problem is: I don't know what to do in order to import into the widget.
Here's what i've tried:
So, what can i do to import jsPDF into my widget and widget only? I want to be able to drag and drop the widget folder into other apps in the future for easy modifications.
Solved! Go to Solution.
Matheus,
I am not sure what you are doing wrong then. I just added a third party library to one of my widgets and it worked fine.
define([
'dojo/on',
'dojo/query',
'./rcolor'
...
function(on, query, rColor, ...
So I have a file called rcolor.js in my widgets folder, and it just works.
https://developers.arcgis.com/web-appbuilder/sample-code/add-a-third-party-library.htm
Put the library in the widget or theme folder and add it to your widget or theme dependency array. Use this approach to load an AMD module that only applies to one widget or theme.
And how exactly do i do that? I've tried adding it to the define array and then the function array. But it still won't work.
Matheus,
I am not sure what you are doing wrong then. I just added a third party library to one of my widgets and it worked fine.
define([
'dojo/on',
'dojo/query',
'./rcolor'
...
function(on, query, rColor, ...
So I have a file called rcolor.js in my widgets folder, and it just works.
It seemed to have worked as the widget now loads. Thank you. Now i've to solve the 'jsPDF is not a constructor' error.