D
D
DamWolf2020-10-27 15:15:59
PDF
DamWolf, 2020-10-27 15:15:59

How to make PDF from HTML using jsPDF?

I can't make PDF-ku from html on the page in any way. Tell me what's wrong please
Here is the code:

HTML:

<div id = "pdf">
Что-то написано
</div>

<input type = "checkbox" name = "choose-1" id = "checkbox-1" onclick = "getPDF()" >


javascript:
<script src = "https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js">
import { jsPDF } from "jspdf";
</script>

function getPDF() {
  var specialElementHandlers = {
    '#elementH': function (element, renderer) {
        return true;
    },
  '.controls': function(element, renderer){
      return true;
    }
};
  
  var doc = new jsPDF();
  
  doc.fromHTML($('#pdf').get(0), 15, 15,{
    'width': 170,
    'elementHandlers': specialElementHandlers
});
  
  doc.save('Test.pdf');
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question