Utilizing jsPDF, I was able to generate a table from JSON data and store it in a PDF document. To showcase this functionality, I developed an Angular2/Typescript application. This application creates a table based on my JSON data. My goal now is to use jsPDF to create a table with horizontal headers as demonstrated in the example here. The code snippet for achieving this task is provided below.
// Horizontal - shows how tables can be drawn with horizontal headers
examples.horizontal = function () {
var doc = new jsPDF('p', 'pt');
doc.autoTable(getColumns().splice(1,4), getData(), {
drawHeaderRow: function() {
// Don't draw header row
return false;
},
columnStyles: {
first_name: {fillColor: [41, 128, 185], textColor: 255, fontStyle: 'bold'}
}
});
return doc;
};
The full code can be accessed here. It should be noted that this code is in JavaScript, and I am currently seeking guidance on converting it into Typescript. Any helpful insights would be greatly appreciated!