I have tried many methods but either they have limitation of Number of columns in pdf or they have height limitation. And for excel, when I open in MAC, it shows HTML. Can anyone suggest any way from which I can export pdf with More than 4 columns and does not have limitation on number of rows.
Asked
Active
Viewed 5,671 times
1 Answers
2
You could try to use jsPDF library to do this
HTML
<table id="table">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
</tr>
</thead>
<tbody>
<tr>
...
</tr>
</tbody>
</table>
<export-to-pdf elem-id="table"></export-to-pdf>
JS
app.directive('exportToPdf', function(){
return {
restrict: 'E',
scope: {
elemId: '@'
},
template: '<button data-ng-click="exportToPdf()">Export to PDF</button>',
link: function(scope, elem, attr){
scope.exportToPdf = function() {
var doc = new jsPDF();
console.log('elemId 12312321', scope.elemId);
doc.fromHTML(
document.getElementById(scope.elemId).innerHTML, 15, 15, {
'width': 170
});
doc.save('a4.pdf')
}
}
}
});
In my JSFiddle example I didnt reach limit for columns, but I did not find solution about adding css, so you have to do inline styling for html code

Leguest
- 2,097
- 2
- 17
- 20