我正在尝试将谷歌图表的表格保存为pdf。我正在使用下面的代码。
function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#customers')[0];
specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(
source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},
function (dispose) {
pdf.save('Test.pdf');
},
margins);
pdf.save('Test.pdf');
}它工作得很好,并将表保存为pdf。我的问题是如何将其转换为表格格式。pdf中的表格数据是以文本的形式逐行出现的。我使用的是以下链接的代码:
http://jsfiddle.net/xzZ7n/1/我正在获取pdf格式的数据,如下所示:
Country
Population
Date
Age
Chinna
1,363,480,000
March 24, 2014
19.1
India
1,241,900,000
March 24, 2014
17.4
United States
317,746,000
March 24, 2014
4.44
Indonesia
249,866,000
July 1, 2013
3.49
Brazil
201,032,714
July 1, 2013
2.81我需要一个表格格式。
发布于 2015-04-14 21:14:17
确保已包含以下所有脚本文件
<script src="/Scripts/plugin/jsPdf/jspdf.js"></script>
<script src="/Scripts/plugin/jsPdf/jspdf.plugin.standard_fonts_metrics.js"> </script>
<script src="/Scripts/plugin/jsPdf/jspdf.plugin.split_text_to_size.js"></script>
<script src="/Scripts/plugin/jsPdf/jspdf.plugin.from_html.js"></script>
<script src="/Scripts/plugin/jsPdf/jspdf.plugin.addimage.js"></script>
<script src="/Scripts/plugin/jsPdf/FileSaver.min.js"></script>
<script src="/Scripts/plugin/jsPdf/jspdf.debug.js"></script>https://stackoverflow.com/questions/29558409
复制相似问题