1

hello e been looking for how to export an html containing tables with styles and several goocharts in image format I can do with jsPDF but I realized that the tables in this library do not receive css styles and also if the texts are very long they leave the cells and get lost

I tried with jspdf dompdf html2pfd

function reporGeneralPDF() {var pdf = new jsPDF('p', 'pt', 'a4');
  source = $('#pdf')[0];

  specialElementHandlers = {
    '#bypassme': function (element, renderer) {
      return true
    }
  };
  margins = {
    top: 80,
    bottom: 60,
    left: 40,
    right: 30,
    width: 500
  };

  pdf.fromHTML(
    source,
    margins.left, // x coord
    margins.top, { // y coord
      'width': margins.width,
      'elementHandlers': specialElementHandlers
    },

    function (dispose) {
      pdf.save('Reporte.pdf');
    }, margins
  );
}

If someone knows some method, library or at least one way to solve the problem with the tables in jspd I would appreciate it enough because it would help me too much

j08691
  • 204,283
  • 31
  • 260
  • 272
  • Not sure if you can still see it (my answer got deleted because I only added a link - I just updated with more details). I'm pretty sure that it is what you are looking for. Thanks – Carlos27 Jun 10 '19 at 18:45
  • I had done something similar using ImageMagic lib. You have to send the HTML contents to convert it to JPEG and then generate PDF using html2pdf. So basically, send the source of the page to the ImageMagic – Anand G Jun 10 '19 at 18:45
  • Good day on the first comment does not reach to see any link:/ And on the second is not think that I miss comment that the data of tables or table can not be burned as an image should be accessible to and another problem I found is that when the table many rows to be divided into two sheets the title of the table goes over the P Second sheet row Rimer – William Naranjo Jun 14 '19 at 02:46

1 Answers1

0

good guys the solution menojr that I found the challenge was this even if I do not achieve with the styles is a good solution because it gives a very good presentation I hope it serves someone as well as my

How to print HTML content on click of a button, but not the page?

 function generatePdf() {

 var printContents = document.getElementById('pdf').innerHTML;
 var originalContents = document.body.innerHTML;
 document.body.innerHTML = printContents;
 window.print();
 document.body.innerHTML = originalContents;
 }