需要添加日期
Need to Add Date
所以我试图将当前日期添加到一个脚本中,该脚本在使用 jspdf 和 autotable.src.js 单击按钮时生成 PDF。我想在文档标题的正下方添加日期....
<script>
function generate() {
// header
var doc = new jsPDF('l', 'pt');
<?php include 'imgData.php';?>
doc.addImage(imgData, 'JPEG', 40, 20, 60, 60);
// xy coords width height
doc.text(107, 58, "Movies");
// ADD DATE HERE
var m_names = new Array("January", "February", "March",
"April", "May", "June", "July",
"August", "September",
"October", "November", "December");
var today = new Date();
var curr_date = today.getDate();
var curr_month = today.getMonth();
var curr_year = today.getFullYear();
today = m_names[curr_month] + " " + curr_date + ", " + curr_year;
var newdat = today;
doc.setFontType("italic");
doc.setFontSize(10);
doc.text(107, 74, newdat);
// DATE END
// data
var res = doc.autoTableHtmlToJson(document.getElementById("movie"));
// footer
var totalPagesExp = "{total_pages_count_string}";
var footer = function (data) {
var str = "Page " + data.pageCount;
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp + " - The Movie Connection (LTD) ";
}
doc.text(str, data.settings.margin.left, doc.internal.pageSize.height - 30);
};
// options
var options = {
headerStyles: {
//fillColor: [104, 163, 194],
valign: 'middle',
rowHeight: 28,
fontSize: 11
},
bodyStyles: {
overflow: 'linebreak', // visible, hidden, ellipsize or linebreak
columnWidth: 300,
rowHeight: 24
},
afterPageContent: footer,
margin: {
top: 90
}
};
doc.autoTable(res.columns, res.data, options);
// Total page number plugin only available in jspdf v1.0+
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
}
doc.save("movies.pdf");
};
有什么想法吗?
试试这个:-
var today = new Date();
var newdat = "Date Printed : "+ today;
doc.text(107,68,newdat);
所以我试图将当前日期添加到一个脚本中,该脚本在使用 jspdf 和 autotable.src.js 单击按钮时生成 PDF。我想在文档标题的正下方添加日期....
<script>
function generate() {
// header
var doc = new jsPDF('l', 'pt');
<?php include 'imgData.php';?>
doc.addImage(imgData, 'JPEG', 40, 20, 60, 60);
// xy coords width height
doc.text(107, 58, "Movies");
// ADD DATE HERE
var m_names = new Array("January", "February", "March",
"April", "May", "June", "July",
"August", "September",
"October", "November", "December");
var today = new Date();
var curr_date = today.getDate();
var curr_month = today.getMonth();
var curr_year = today.getFullYear();
today = m_names[curr_month] + " " + curr_date + ", " + curr_year;
var newdat = today;
doc.setFontType("italic");
doc.setFontSize(10);
doc.text(107, 74, newdat);
// DATE END
// data
var res = doc.autoTableHtmlToJson(document.getElementById("movie"));
// footer
var totalPagesExp = "{total_pages_count_string}";
var footer = function (data) {
var str = "Page " + data.pageCount;
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp + " - The Movie Connection (LTD) ";
}
doc.text(str, data.settings.margin.left, doc.internal.pageSize.height - 30);
};
// options
var options = {
headerStyles: {
//fillColor: [104, 163, 194],
valign: 'middle',
rowHeight: 28,
fontSize: 11
},
bodyStyles: {
overflow: 'linebreak', // visible, hidden, ellipsize or linebreak
columnWidth: 300,
rowHeight: 24
},
afterPageContent: footer,
margin: {
top: 90
}
};
doc.autoTable(res.columns, res.data, options);
// Total page number plugin only available in jspdf v1.0+
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
}
doc.save("movies.pdf");
};
有什么想法吗?
试试这个:-
var today = new Date();
var newdat = "Date Printed : "+ today;
doc.text(107,68,newdat);