JsPDF Tutorial to Insert JSON Objects Data Inside PDF Document in Browser Using Javascript

jsPDF Tutorial to Insert JSON Objects Data inside PDF Document in Browser Using Javascript

<head>
  <script     src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.debug.js"></script>
 
</head>
<body>
  <h1>This code pen will generate PDF from json and save it at client side.
</h1>
</body>
<script>
  var employees = [
    {"firstName":"utsav", "lastName":"Maniyar"},
    {"firstName":"heta", "lastName":"yadav"},
    {"firstName":"run", "lastName":"run"}
];
 
var doc = new jsPDF();
employees.forEach(function(employee, i){
    doc.text(50, 10 + (i * 10),
        "First Name: " + employee.firstName +
        " Last Name: " + employee.lastName);
});
doc.save('Test.pdf');
  </script>

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment