1

Please check the link https://jsfiddle.net/dhaileytaha/1wmk9gsq/14/

<script>
 /*Download option*/
var doc = new jsPDF();
    var specialElementHandlers = { 
 '#editor': function (element, renderer) {
        return true;
    }
    };
          doc.fromHTML($('#example').html(), 55, 55, {
        'width': 170,
    'elementHandlers': specialElementHandlers
    });


document.getElementById("cmd").onclick = function () {

    var pass1= "cool" ;

password=prompt('Please enter your password to Print this page!',' ');

if (password==pass1)
{ 
       doc.save('target-file.pdf');
   } else {
       window.alert('Sorry! You are not Authorsised');   
   }
 }

</script>

it is a datatable. I am able to print it in proper format but not able to download in the same FORMAT as the datatable is. Please help I want the same format as of the DATATABLE in pdf form.

tryintolearn
  • 53
  • 2
  • 8
  • Look at this post: a nice working example attached. http://stackoverflow.com/questions/16858954/how-to-properly-use-jspdf-library – lastboy Mar 29 '16 at 09:34

1 Answers1

0

Your jspdf resource you are using is an old one probably and does not work properly.

Another thing you should do, is wrap the content with a div tag.

I tried out your fiddle example with the following version and it works. http://mrrio.github.io/jsPDF/dist/jspdf.debug.js

lastboy
  • 566
  • 4
  • 12