HTML2PDF.js Tutorial to Add Headings,Images,Buttons and Hyperlinks in PDF Document in Browser Using Javascript Full Project For Beginners







<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML2PDF Add Image in PDF Document</title>
    <div id="profile">
    <h1>Add Image in PDF Document</h1>
    <a target="_blank" href="">Google</a><br>
    <img src="profile.jpg"/>
    <button onclick="pdf()">Download PDF</button>
<script src=""></script>
    function pdf(){
        var element = document.getElementById('profile');
var opt = {
  margin:       1,
  filename:     'myfile.pdf',
  image:        { type: 'jpeg', quality: 0.98 },
  html2canvas:  { scale: 2 },
  jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait' }

// New Promise-based usage:



Leave a Reply