Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 How to convert HTML Code to PDF in JSP:-

JSP uses many JS libraries to convert HTML code under pDF files.


How to use it?

1) import JS Script

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js" ></script>


2)   Write JS Script of PDF under head section


<script>

function generatePDF() {

var doc = new jsPDF();  //create jsPDF object

  doc.fromHTML(document.getElementById("test"), // page element which you want to print as PDF

  15,

  15, 

  {

    'width': 170  //set width

  },

  function(a) 

   {

    doc.save("HTML2PDF.pdf"); // save file name as HTML2PDF.pdf

  });

}

</script>


3) Write code under page element

  <div id="test">

       <p><font size="3" color="red">About Me</font></p>

       <p><font size="10" color="green"><%





%></font></p>

  

    </div>

    

<a href="javascript:generatePDF()">Dowload PDF</a>


...............................................................


Create Resume Maker Software in JSP and publish live on Heroku cloud server.

Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post