jsPDF with colspan at the top of the table

Asked

Viewed 342 times

0

i am trying to assemble a pdf based on the image below

inserir a descrição da imagem aqui

I can manage the pdf, but without the line with "Info" and "Contact". It is possible to generate the pdf in the same way as in the image?

That’s what I’ve been able to do so far

this.pdf = function(title, table, hideInfo) { 
 var doc = new jsPDF('l', 'pt', 'a4'), start = 65;

 doc.setFont('helvetica');
 doc.setFontSize(8);
 doc.text(title, (doc.internal.pageSize.width - 
 doc.getStringUnitWidth(title) * 8) / 2, 50);
 doc.setFontSize(6);

 doc.autoTable(table.columns, table.data, {
 startY: start,
 margin: { horizontal: 25 },
 styles: { overflow: 'linebreak', fontSize: 6, font: 'helvetica' },
 bodyStyles: { valign: 'top' },
 pageBreak: 'auto',
 theme: 'grid',
 columnWidth: 'wrap',
 headerStyles: { fillColor: [20, 167, 146] },
 drawCell: function(cell, data) {
 if (data.row.raw[0] && data.row.raw[0].toString().trim().toLowerCase() === 'total') {
  doc.setFillColor(233, 233, 233);
  doc.setFontType("bold");
 }
}}); 
doc.save(title.replace(/ /g,"_") + '.pdf');};
  • Are you rendering HTML? or are you generating Angular inside ngfor?

  • I’m generating by angular, I have an object and use ng-repeat

  • try the plugin Autotable

  • tomasantunesw, I’m already using this plugin, what I haven’t been able to do so far is add the colspan at the top of the table. I added the code I’ve made so far.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.