I have integrated FileSaver.js, jspdf.plugin.table.js, and jspdf.js files into my project. Below is the code snippet from my controller:
$scope.exportPdf = function(sampletable){
alert('pppp');
var tbldata = [], fontSize = 8, height = 0, doc;
doc = new jsPDF('p', 'pt', 'a4', true);
doc.setFont("times", "normal");
doc.setFontSize(fontSize);
tbldata = [];
tbldata = doc.tableToJson('sampletable');
height = doc.drawTable(tbldata, {
});
// doc.text(120, height + 20, 'Congrats!');
doc.save("dwnld.pdf");
}
However, I am facing issues when trying to include an image within my table. The current setup does not support tables with images. My table structure is as follows:
<style>
.tab{
margin-left:10%;
}
.table1, .tr1 ,.td1{
border: 1px solid black;
}
th, td {
padding: 5px;
}
</style>
<table border="1" style="width:80%" class="table1 tab" ng-repeat="m in empname" id="sampletable">
<tr class="tr1">
<td class="td1">Name</td>
<td class="td1">uu</td>
<td class="td1">hh</td>
<td class="td1">uu</td>
</tr>
<tr class="tr1">
<td class="td1">uuu</td>
<td class="td1">hhh</td>
<td class="td1">iit</td>
<td class="td1">iii</td>
</tr>
<tr class="tr1">
<td class="td1">Nojjjjjj</td>
<td class="td1">22</td>
<td class="td1">yyyyyy</td>
<td class="td1">21</td>
</tr>
<tr class="tr1">
<th height="50" colspan="4">yyyyyyyyyy</th>
</tr>
<tr class="tr1">
th colspan="4" class="td1">hhhhhhhh</th>
</tr>
<tr class="tr1" >
<td class="td1" colspan="2">hh</td>
<td class="td1" colspan="2">hh</td>
</tr>
<tr class="tr1">
<td class="td1" colspan="2">hhhhh</td><td class="td1" colspan="2">888</td>
</tr>
<tr class="tr1">
<th height="100" colspan="4" >ggggggggggggggggggggg bbbbbbbbbbbb</th>
</tr>
</table>
Although I'm able to generate a PDF file, it doesn't meet my requirements precisely. Any assistance in resolving this issue would be greatly appreciated.