0

i tried this but did not got the output

function downloadInnerHtml(filename, elId) {

    var elHtml = $(elId).pdf();
    var link = document.createElement('a');
    var mimeType = mimeType/'pdf';
    link.setAttribute('download', filename);
    link.setAttribute('href','data:' + mimeType + ';charset=utf-8,' +    encodeURIComponent(elHtml));
    link.click();
}

 $(document).ready(function () {

 $('#download').click(function () {

                downloadInnerHtml(fileName, 'table4');
            });
 });
大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
sunitha
  • 9
  • 1
  • 5

1 Answers1

1
<a href="#" class="btn btn-primary" onclick='printDiv();'>Download Resume</a>

<div class="section-body" id="DivIdToPrint">
      ....
      ....
</div>

<script>
   function printDiv() 
   {
       var divToPrint=document.getElementById('DivIdToPrint');
       var newWin=window.open('','Print-Window');
       newWin.document.open();
       newWin.document.write('<html><head> 'link your used css'</head><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
       newWin.document.close();
       setTimeout(function(){ newWin.close(); }, 10);
   }
</script>
Sowmyadhar Gourishetty
  • 1,843
  • 1
  • 8
  • 15