<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using jsPDF in custom widget in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-jspdf-in-custom-widget/m-p/1040817#M72213</link>
    <description>&lt;P&gt;I&amp;nbsp; simplified the code for testing and was able to download a PDF (finally). These are the changes I made:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. added &lt;EM&gt;dojo/domReady,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;2. changed&amp;nbsp; &amp;nbsp;&lt;EM&gt; new jsPDF()&lt;/EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;to&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;new jsPDF.jsPDF()&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;3.&amp;nbsp;&lt;/EM&gt;updated the URL of the third party library to&amp;nbsp;&lt;EM&gt;&lt;A href="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js" target="_blank"&gt;https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js&lt;/A&gt;&lt;/EM&gt; so that it uses the latest version.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One other thing to note, is that in my original post i called doc.fromHTML() in accordance with the code sample i referenced. But when i take a look at the console log --&amp;gt; console.log("this is the doc: ", doc)&amp;nbsp; I do not see fromHTML(). So maybe that was just from a past version of the library? I am not sure, I could be reading the console.log wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrackstonLand_0-1616702972427.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/9419i333BC21D5AEF4556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrackstonLand_0-1616702972427.png" alt="BrackstonLand_0-1616702972427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the Javascript code, hopefully it help point someone in the right direction.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare', 
'jimu/BaseWidget',
'https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js',
//'./widgets/Testing_PDF_Stuff/libs/jsPDF-master/dist/jspdf.umd.min.js',
'jimu/loaderplugins/jquery-loader!https://code.jquery.com/jquery-3.4.1.js,https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.js',	
'dojo/domReady!'
],


function(
declare, 
BaseWidget,
jsPDF,
$,
domReady) 
{

  return declare([BaseWidget], {

    baseClass: 'jimu-widget-Testing_PDF_Stuff',
	
    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },
	

    startup: function() {
        this.inherited(arguments);
		
		$('#cmd').click(function () {
			
		const doc = new jsPDF.jsPDF();
		
		doc.text("Hello world!", 10, 10);
		doc.save("a4.pdf");		
		}); 
    }

  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 20:11:27 GMT</pubDate>
    <dc:creator>B-L</dc:creator>
    <dc:date>2021-03-25T20:11:27Z</dc:date>
    <item>
      <title>Using jsPDF in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-jspdf-in-custom-widget/m-p/1040740#M72211</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to use a third party library (jsPDF) in my custom widget and I am getting the error&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;jsPDF is not a constructor&lt;BR /&gt;at Object.startup&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I am using the code here&amp;nbsp;&lt;A href="https://jsfiddle.net/j8cnsdw3/" target="_blank" rel="noopener"&gt;Edit fiddle - JSFiddle - Code Playground&lt;/A&gt;. I would greatly appreciate it if&amp;nbsp; anyone can help me understand why the code is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Javascript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare', 
'jimu/BaseWidget',
'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js',
//'./widgets/JointUseWidget/libs/jsPDF-master/dist/jspdf.node.min.js',
'jimu/loaderplugins/jquery-loader!https://code.jquery.com/jquery-3.4.1.js,https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.js'	
],


function(
declare, 
BaseWidget,
jsPDF,
$) 
{

  return declare([BaseWidget], {

    baseClass: 'jimu-widget-Testing_PDF_Stuff',

    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },

    startup: function() {
      this.inherited(arguments);
		var doc = new jsPDF();
		var specialElementHandlers = {
			'#editor': function (element, renderer) {
				return true;
			}
		};

		$('#cmd').click(function () {
			doc.fromHTML($('#content').html(), 15, 15, {
				'width': 170,
					'elementHandlers': specialElementHandlers
			});
			doc.save('sample-file.pdf');
		});

    },
	
	


  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div&amp;gt;

  &amp;lt;div id="content"&amp;gt;
     &amp;lt;h3&amp;gt;Hello, this is a H3 tag&amp;lt;/h3&amp;gt;

    &amp;lt;p&amp;gt;a pararaph&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div id="editor"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;button id="cmd"&amp;gt;Generate PDF&amp;lt;/button&amp;gt;


&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 19:17:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-jspdf-in-custom-widget/m-p/1040740#M72211</guid>
      <dc:creator>B-L</dc:creator>
      <dc:date>2021-03-25T19:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using jsPDF in custom widget</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-jspdf-in-custom-widget/m-p/1040817#M72213</link>
      <description>&lt;P&gt;I&amp;nbsp; simplified the code for testing and was able to download a PDF (finally). These are the changes I made:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. added &lt;EM&gt;dojo/domReady,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;2. changed&amp;nbsp; &amp;nbsp;&lt;EM&gt; new jsPDF()&lt;/EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;to&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;new jsPDF.jsPDF()&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;3.&amp;nbsp;&lt;/EM&gt;updated the URL of the third party library to&amp;nbsp;&lt;EM&gt;&lt;A href="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js" target="_blank"&gt;https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js&lt;/A&gt;&lt;/EM&gt; so that it uses the latest version.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One other thing to note, is that in my original post i called doc.fromHTML() in accordance with the code sample i referenced. But when i take a look at the console log --&amp;gt; console.log("this is the doc: ", doc)&amp;nbsp; I do not see fromHTML(). So maybe that was just from a past version of the library? I am not sure, I could be reading the console.log wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrackstonLand_0-1616702972427.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/9419i333BC21D5AEF4556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrackstonLand_0-1616702972427.png" alt="BrackstonLand_0-1616702972427.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the Javascript code, hopefully it help point someone in the right direction.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare', 
'jimu/BaseWidget',
'https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js',
//'./widgets/Testing_PDF_Stuff/libs/jsPDF-master/dist/jspdf.umd.min.js',
'jimu/loaderplugins/jquery-loader!https://code.jquery.com/jquery-3.4.1.js,https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.js',	
'dojo/domReady!'
],


function(
declare, 
BaseWidget,
jsPDF,
$,
domReady) 
{

  return declare([BaseWidget], {

    baseClass: 'jimu-widget-Testing_PDF_Stuff',
	
    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },
	

    startup: function() {
        this.inherited(arguments);
		
		$('#cmd').click(function () {
			
		const doc = new jsPDF.jsPDF();
		
		doc.text("Hello world!", 10, 10);
		doc.save("a4.pdf");		
		}); 
    }

  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 20:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-jspdf-in-custom-widget/m-p/1040817#M72213</guid>
      <dc:creator>B-L</dc:creator>
      <dc:date>2021-03-25T20:11:27Z</dc:date>
    </item>
  </channel>
</rss>

