I recently built a page using AngularJS that utilizes the ng-repeat tag to display data in a table. I added some custom formatting and colspan functionality to enhance the appearance of the table. Now, my goal is to export this table into a PDF file. So far, I have experimented with various methods:
htmltoCanvas: Here's an example of the code I used:
$scope.export = function(){ html2canvas(document.getElementById('exportthis'), { onrendered: function (canvas) { var data = canvas.toDataURL(); var pdf = new jsPDF('landscape','pt','letter'); pdf.addImage(data, 'JPEG', 0, 0); pdf.save("download.pdf"); } }); }
However, I encountered some challenges. When converting the table to an image, I found that I could not copy the text contents. Additionally, for larger tables that span multiple pages, the resulting PDF would turn out blank.
- I also tried using jspdf, but unfortunately, it does not support colspan and the formatting gets lost in the process.
If anyone has any suggestions or solutions to overcome these obstacles, please let me know. Thank you!