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

将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 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体