JsPDF Tutorial to Draw Colored & Filled Rectangle and Write Some Text Over It in PDF Document Using Javascript

You are currently viewing JsPDF Tutorial to Draw Colored & Filled Rectangle and Write Some Text Over It in PDF Document Using Javascript

jsPDF Tutorial to Draw Colored & Filled Rectangle and Write Some Text Over it in PDF Document Using Javascript

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://parall.ax/parallax/js/jspdf.js"></script>
  <body>
      <button onclick="generatePDF()">Generate PDF</button>
  </body>
  <script>
      function generatePDF() {
 
      
        var doc = new jsPDF();
 
doc.setFontSize(17);
 
doc.setFillColor(0,0,0);
doc.rect(100, 20, 60, 10, 'F');
 
doc.setTextColor(255, 255, 255);
doc.text(100,28, 'USD.00');
 
        doc.save("output.pdf")
    }
 
    </script>
  </script>
  </html>

Ranjith

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

Leave a Reply