dongnaoben4456
2019-06-10 18:02
浏览 555

将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

图片转代码服务由CSDN问答提供 功能建议

你好我一直在寻找如何导出包含样式的html表格以及图像格式的几个goocharts我可以用 jsPDF,但我意识到这个库中的表不接收CSS样式,如果文本很长,它们会离开单元格并迷路

我尝试使用jspdf dompdf html2pfd

  function reporGeneralPDF(){var pdf = new jsPDF('p','pt','a4'); 
 source = $('#pdf')[0];  
 
 specialElementHandlers = {
'#bypassme':function(element,renderer){
 return true 
} 
}; 
 margin = {
 top:80,
 bottom:60,\  n left:40,
 right:30,
 width:500 
}; 
 
 pdf.fromHTML(
 source,
 marginins.left,// x coord 
 margins.top,{/  / y coord 
'width':margins.width,
'elementHandlers':specialElementHandlers 
},
 
 function(dispose){
 pdf.save('Reporte.pdf'); 
},  margin 
); 
} 
   
 
 

如果有人知道s ome方法,库或至少一种方法来解决jspd中表的问题我会很感激,因为它会帮助我太多

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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;
     }
    
    点赞 评论

相关推荐 更多相似问题