Nidhi Donga

Nidhi Donga

  • NA
  • 88
  • 8.9k

pdf generation using javascript is not working

Sep 18 2019 10:49 PM
hey, 
i am using below code to print the div as a pdf but i get blank page as a pdf so please help me. 
 
 
<script type="text/javascript">
         $(function () {
             $('#btnPrint').click(function () {
                 var doc = new jsPDF();
                 doc.fromHTML($('#pnlContents').html(), 15, 15, { 'width': 170 });
                 doc.save('sample.pdf');
                 return false;
             });
         });
</script>
 
 
<div class="pnlContents">
<br />
<b><i>Hi
<asp:Label ID="lbl_name" runat="server" Text=""></asp:Label>,
<br />
<asp:Label ID="lbl_addr" runat="server" Text=""></asp:Label>,
<br />
<asp:Label ID="lbl_dist" runat="server" Text=""></asp:Label>,
<asp:Label ID="lbl_state" runat="server" Text="Label"></asp:Label>
<br />
Phone:
<asp:Label ID="lbl_phone" runat="server" Text=""></asp:Label>
<br />
Email:
<asp:Label ID="lbl_email" runat="server" Text=""></asp:Label>
</i></b>
<hr />
<p>
Thank you for using the System - AgriIrriGreat to design the Sprinkler irrigation system for your field.
The design of Sprinkler irrigation system is based on the data inputted by you.
Besides a suitable layout plan and its design details, AgriIrriGreat also provides a cost estimate based on the indicative prices of different components of the Sprinkler irrigation system.
</p>
<hr />
<h2>Data Provided By User:</h2>
<table class="table table-bordered table-striped table-hover">
<tr>
<td>
<b>Lenght of Field (m):</b>
<asp:Label ID="lbl_length" runat="server" Text="Label"></asp:Label>,
<b>Width of field (m):</b>
<asp:Label ID="lbl_width" runat="server" Text="Label"></asp:Label>,
<b>Crop to be grown:</b>
<asp:Label ID="lbl_crop" runat="server" Text="Label"></asp:Label>,
<b>Source of water:</b>
<asp:Label ID="lbl_source" runat="server" Text="Label"></asp:Label>,
<b>Location of water source:</b>
<asp:Label ID="lbl_location" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<hr />
</div>
 
 

Answers (2)