0

I am trying to download in PDF format in lightning component. I have added jsDPF zip file in static resource. Static rescource name:jsPDF, zipFile name:jsPDF,Folder name:jsPDF-1.3.2

On previewing application, I am getting below error: enter image description here

screeenshotPDF.cmp

<aura:component >   
<ltng:require scripts="/resource/jsPDF/jsPDF-1.3.2/jspdf.js"
              afterScriptsLoaded="{!c.doInit}"/>
<div id="prinpdf"><h1>Ejemplo PDF</h1></div>

screeenshotPDFController.js

({
doInit : function(component, event, helper) {
    var pdf = new jsPDF();
    var canvas = pdf.canvas;
   //canvas.height = 72 * 11;
    //canvas.width= 72 * 8.5;;

    // can also be document.body
    var text = document.getElementById('prinpdf');
    pdf.text(20, 20, 'prinpdf');
    pdf.save('Test.pdf');
}
})

jsPDF_Test_App.app

<aura:application >
    <c:screeenshotPDF/>
 </aura:application>
2
  • 1
    can you change your component api version to 39 and try ? just trying to rule out if its because of locker service
    – RedDevil
    Commented Jul 13, 2018 at 10:15
  • I changed it to 39 and still error persists
    – devforce
    Commented Jul 13, 2018 at 10:18

1 Answer 1

4

I changed my reference to jspdf.debug.js and it worked

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .