dongnaoben4456 2019-06-10 18:02
浏览 808
已采纳

将html和google图表导出为pdf而不会丢失样式css

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

  • 写回答

1条回答 默认 最新

  • doo6568 2019-06-15 01:00
    关注

    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;
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。