0

I am using jspdf.min.js to genarate pdf for my content I am able genarate pdf using jspdf.min.js but i am unable to apply the styles of the elements into my pdf file

See the below for example

var doc = new jsPDF();
var specialElementHandlers = {
 '#editor': function (element, renderer) {
  return true;
 }
};
$('#cmd').click(function () {
 doc.fromHTML($('#content').html(), 15, 15, {
  'elementHandlers': specialElementHandlers
 });
 doc.save('sample-file.pdf');
});
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<div id="content">
  <h3 style="color: red">Hello, this is a H3 tag</h3>
  <p>a pararaph</p>
</div>
<button id="cmd">generate PDF</button>

Here it is not working check the following jsFiddle for the working example

Link: Demo Fiddle

Cœur
  • 37,241
  • 25
  • 195
  • 267
Manikanta Reddy
  • 849
  • 9
  • 23

0 Answers0