简体   繁体   English

使用D3图表和照片将HTML导出为pdf

[英]Export html to pdf with d3 charts and photos

I want to export HTML to PDF with JavaScript, and I tried jsPdf with html2canvas, but not all the charts can show up and photos can't appear.I know html2canvas uses canvas to simulate dom content, so it can't perfectly simulate all the content.Is any other method? 我想使用JavaScript将HTML导出为PDF,并尝试使用html2canvas进行jsPdf,但并非所有图表都可以显示并且照片无法显示。我知道html2canvas使用画布模拟dom内容,因此不能完美地模拟所有内容内容。还有其他方法吗? Thanks! 谢谢! The following is the pdf result: 以下是pdf结果:

在此处输入图片说明

expected result 预期结果 在此处输入图片说明

Apache has a library called Apache batik .It convert SVG image to raster format pdf/png/word etc. Its difficult to convert svg element directly from the UI into raster format. Apache有一个名为Apache batik的库。它将SVG图像转换为栅格格式pdf / png / word等。很难将svg元素直接从UI转换为栅格格式。 Batik is a best approach to implement. 蜡染是实现的最佳方法。 It has been implemented is in java . 它已在java中实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM