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

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

我尝试使用jspdf dompdf html2pfd </ p >

  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
);
}
</ code> </ pre>

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

展开原文

原文

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

dongyan3853
dongyan3853 第一个评论的好日子没有达到任何链接:/并且第二个不认为我错过评论表或表的数据不能被烧毁,因为图像应该是可访问的,我发现的另一个问题是当表中许多行被分成两张时,表的标题将超过P第二张表Rimer
一年多之前 回复
dozpox8752
dozpox8752 我使用ImageMagiclib做了类似的事情。您必须发送HTML内容以将其转换为JPEG,然后使用html2pdf生成PDF。所以基本上,将页面源发送到ImageMagic
一年多之前 回复
donglaogu3788
donglaogu3788 不确定你是否还能看到它(我的答案被删除了,因为我只添加了一个链接-我刚刚更新了更多细节)。我很确定这就是你要找的东西。谢谢
一年多之前 回复

1个回答



好人解决方案menojr,我发现挑战是这个,即使我没有实现样式是一个很好的解决方案,因为它给出 一个非常好的演示文稿我希望它能为我和某人提供服务</ p>

如何点击按钮打印HTML内容,而不是页面? </ p>

  function generatePdf(){

var printContents = document.getElementById('pdf')。innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</ code> </ pre>
</ div>

展开原文

原文

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;
 }

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问