jsPDF-AutoTable:在页面上显示多个页脚,并排绘制多个水平表格
jsPDF-AutoTable: Showing multiple footers on page with more than one horizontal tables drawn side by side
我用 jsPDF-AutoTable 创建了多个 table,并排放置。这些 table 内容因我的 HTML 页面中的数据而异。因此,同一页上可能并排存在多个 table。
我面临的问题是 为每对 table 创建页脚,这样页脚就会在每一页上重叠。
这是我的 PDF 文件的图像。
const pdf = new jsPDF('l', 'pt',);
const totalPagesExp = '{total_pages_count_string}';
let first = null, last = null;
const footer = function (data) {
var imgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGkAAABgCAYAAAAejVzyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6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fl/CgfYcLBNJe0Tk/THOqmXLQ1oNGZZq+Ff7rm4CVm52fh2ZTz53P8n19LO6rVwFAooS/ZqfRyfE2Zn5q4fBiwl/CohxUM7g1n43oa5zv6MnMr41ySipRYEcQzFomrmObuK++eSYcqOMxv+026uD9S9uKBrvCgXIP5aBFcf9EjUTDsGojx1V9L7PrtSscxjwofjyYcF9DjeO9mqXNmidRx/PNrY06kz75ZmrMymK5Z1DCjOhEkbQfWuud/CV1x3e2NgqdI37k7Woh16bP54pwcv19wC0DgK6dnB9PueewCGsdTda37T5of0p7q/C86Xdm6b7uEvc1WdzXIO8WpLiWkwb2NuT3nFXOj6WcQ7mHQmW8d8ZafQ2w+q82xUc0x/SszNJ9VRvye87yAikLzRoHPPGa+NR/6Ow4yjkULs1C5c+GGF9ythr7bH7b+LNn9eOzmz9o3R39/t0HvYHk6mohCnOUq+pFkn3zEbnIiBl5CuWcebXm59UFhMgNO/a1VgOo06jFG62TozBHg89U6s5u5SLpvjobuaq+QdzXYvch5dVCFI37ENZKEOZ+cFYY/6eiwwnLAdyOnP9fFfRHNiICTkjzQ2Ml0Y8Wisn+4M91rwkJrwF5TXGBueBFom3PKUj03aYI/esdAUZDUXpNkhe5Lhxse40Oxsg1YMVNJdGL2hWS4TUlOhzlNeZe1C6QtKgICAs4ymusvcgzSKTQwno4U17j1Itch0TSmfKM7jWKSlpe5AqkVq8hhaYWI2XqRVmFpLzGHS/KGBL9SeaIgBLSSnW1piz7XpQ2pAioGuA3xjXKXPUiR5CU17SPF9mCpBc3hcdElNe0ixeZQtIQV9xUXtOuXtQGkv61fJTo1YAIL1HdliNepEPSvYZHvYYrr8k1LyL7vwADAHG5t/RI4Vz9AAAAAElFTkSuQmCC'
// HEADER
pdf.setFontSize(20);
pdf.setTextColor(40);
pdf.setFontStyle('normal');
if (imgData)
pdf.addImage(imgData, 'JPEG', 400, 30, 60, 60);
let str = 'Page ' + pdf.internal.getNumberOfPages();
if (typeof pdf.putTotalPages === 'function')
str = str + ' of ' + totalPagesExp;
pdf.setFontSize(10);
pdf.setFontStyle("normal");
pdf.text(str, data.settings.margin.left + 470, pdf.internal.pageSize.height - 30);
pdf.text('© 2019 mysite.com All Rights Reserved.', data.settings.margin.left, pdf.internal.pageSize.height - 30);
};
let y = 120;
$(".note").each(function () {
const $frnt = $(this).find(".front");
const $back = $(this).find(".back");
y = pdf.autoTable.previous ? (first.finalY > last.finalY ? first.finalY + 25 : last.finalY + 25): y;
pdf.autoTable({
head: [[$frnt.find(".bk-title").text().trim().toString(), $frnt.find(".pgno").text().trim()]],
body: [[{
content: $back.find(".question").text().trim().toString(),
colSpan: 2,
styles: {halign: 'justify'}
}]],
startY: y,
tableWidth: 200,
styles: {
cellWidth: 'wrap',
valign: 'middle',
font: 'times',
fontSize: 12,
overflow: 'linebreak'
},
headStyles: {
fillColor: [247, 185, 7]
},
theme: 'striped',
margin: {top: 150, right: 350},
didDrawPage: footer
});
first = pdf.autoTable.previous;
pdf.autoTable({
head: [[$frnt.find(".bk-title").text().trim().toString(), $frnt.find(".pgno").text().trim()]],
body: [[{content: $frnt.find(".title").text().trim().toString(), colSpan: 2, styles: {halign: 'justify'}}],
[{content: $frnt.find(".desc").text().trim().toString(), colSpan: 2, styles: {halign: 'justify'}}]],
startY: y,
styles: {
cellWidth: 'wrap',
valign: 'middle',
font: 'times',
fontSize: 12,
overflow: 'linebreak'
},
headStyles: {
fillColor: [247, 185, 7]
},
theme: 'striped',
margin: {top: 150, left: 340}
});
last = pdf.autoTable.previous;
if (typeof pdf.putTotalPages === 'function')
pdf.putTotalPages(totalPagesExp);
});
pdf.save(`${username}'s Notes.pdf`);
我该如何解决这个问题?
最后,我从here找到了解决方案。
这里 tables 是动态添加的。当页面上有多个 table 时,页脚会添加对应于每个 table。这就是页脚重叠的原因。基于上述解决方案,我将 footer()
函数的代码更改如下:
let currentpage = 0;
const footer = function (data) {
if (currentpage < pdf.internal.getNumberOfPages()) {
var imgData = 'data:image/png;base64,iVBORw0KGgoAAAANSU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Xdm6b7uEvc1WdzXIO8WpLiWkwb2NuT3nFXOj6WcQ7mHQmW8d8ZafQ2w+q82xUc0x/SszNJ9VRvye87yAikLzRoHPPGa+NR/6Ow4yjkULs1C5c+GGF9ythr7bH7b+LNn9eOzmz9o3R39/t0HvYHk6mohCnOUq+pFkn3zEbnIiBl5CuWcebXm59UFhMgNO/a1VgOo06jFG62TozBHg89U6s5u5SLpvjobuaq+QdzXYvch5dVCFI37ENZKEOZ+cFYY/6eiwwnLAdyOnP9fFfRHNiICTkjzQ2Ml0Y8Wisn+4M91rwkJrwF5TXGBueBFom3PKUj03aYI/esdAUZDUXpNkhe5Lhxse40Oxsg1YMVNJdGL2hWS4TUlOhzlNeZe1C6QtKgICAs4ymusvcgzSKTQwno4U17j1Itch0TSmfKM7jWKSlpe5AqkVq8hhaYWI2XqRVmFpLzGHS/KGBL9SeaIgBLSSnW1piz7XpQ2pAioGuA3xjXKXPUiR5CU17SPF9mCpBc3hcdElNe0ixeZQtIQV9xUXtOuXtQGkv61fJTo1YAIL1HdliNepEPSvYZHvYYrr8k1LyL7vwADAHG5t/RI4Vz9AAAAAElFTkSuQmCC'
// HEADER
pdf.setFontSize(20);
pdf.setTextColor(40);
pdf.setFontStyle('normal');
if (imgData)
pdf.addImage(imgData, 'JPEG', 400, 30, 60, 60);
let str = 'Page ' + pdf.internal.getNumberOfPages();
if (typeof pdf.putTotalPages === 'function')
str = str + ' of ' + totalPagesExp;
pdf.setFontSize(10);
pdf.setFontStyle("normal");
pdf.text(str, data.settings.margin.left + 470, pdf.internal.pageSize.height - 30);
pdf.text(`© ${new Date().getFullYear()} 3d-reader.com All Rights Reserved.`, data.settings.margin.left, pdf.internal.pageSize.height - 30);
currentpage = pdf.internal.getNumberOfPages();
}
};
我用 jsPDF-AutoTable 创建了多个 table,并排放置。这些 table 内容因我的 HTML 页面中的数据而异。因此,同一页上可能并排存在多个 table。
我面临的问题是 为每对 table 创建页脚,这样页脚就会在每一页上重叠。
这是我的 PDF 文件的图像。
const pdf = new jsPDF('l', 'pt',);
const totalPagesExp = '{total_pages_count_string}';
let first = null, last = null;
const footer = function (data) {
var imgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGkAAABgCAYAAAAejVzyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTgyQjZCOUY3MDBBMTFFOEExQTBDNzFEQTJGRkQxRUMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTgyQjZCQTA3MDBBMTFFOEExQTBDNzFEQTJGRkQxRUMiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1ODJCNkI5RDc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qXNmidRx/PNrY06kz75ZmrMymK5Z1DCjOhEkbQfWuud/CV1x3e2NgqdI37k7Woh16bP54pwcv19wC0DgK6dnB9PueewCGsdTda37T5of0p7q/C86Xdm6b7uEvc1WdzXIO8WpLiWkwb2NuT3nFXOj6WcQ7mHQmW8d8ZafQ2w+q82xUc0x/SszNJ9VRvye87yAikLzRoHPPGa+NR/6Ow4yjkULs1C5c+GGF9ythr7bH7b+LNn9eOzmz9o3R39/t0HvYHk6mohCnOUq+pFkn3zEbnIiBl5CuWcebXm59UFhMgNO/a1VgOo06jFG62TozBHg89U6s5u5SLpvjobuaq+QdzXYvch5dVCFI37ENZKEOZ+cFYY/6eiwwnLAdyOnP9fFfRHNiICTkjzQ2Ml0Y8Wisn+4M91rwkJrwF5TXGBueBFom3PKUj03aYI/esdAUZDUXpNkhe5Lhxse40Oxsg1YMVNJdGL2hWS4TUlOhzlNeZe1C6QtKgICAs4ymusvcgzSKTQwno4U17j1Itch0TSmfKM7jWKSlpe5AqkVq8hhaYWI2XqRVmFpLzGHS/KGBL9SeaIgBLSSnW1piz7XpQ2pAioGuA3xjXKXPUiR5CU17SPF9mCpBc3hcdElNe0ixeZQtIQV9xUXtOuXtQGkv61fJTo1YAIL1HdliNepEPSvYZHvYYrr8k1LyL7vwADAHG5t/RI4Vz9AAAAAElFTkSuQmCC'
// HEADER
pdf.setFontSize(20);
pdf.setTextColor(40);
pdf.setFontStyle('normal');
if (imgData)
pdf.addImage(imgData, 'JPEG', 400, 30, 60, 60);
let str = 'Page ' + pdf.internal.getNumberOfPages();
if (typeof pdf.putTotalPages === 'function')
str = str + ' of ' + totalPagesExp;
pdf.setFontSize(10);
pdf.setFontStyle("normal");
pdf.text(str, data.settings.margin.left + 470, pdf.internal.pageSize.height - 30);
pdf.text('© 2019 mysite.com All Rights Reserved.', data.settings.margin.left, pdf.internal.pageSize.height - 30);
};
let y = 120;
$(".note").each(function () {
const $frnt = $(this).find(".front");
const $back = $(this).find(".back");
y = pdf.autoTable.previous ? (first.finalY > last.finalY ? first.finalY + 25 : last.finalY + 25): y;
pdf.autoTable({
head: [[$frnt.find(".bk-title").text().trim().toString(), $frnt.find(".pgno").text().trim()]],
body: [[{
content: $back.find(".question").text().trim().toString(),
colSpan: 2,
styles: {halign: 'justify'}
}]],
startY: y,
tableWidth: 200,
styles: {
cellWidth: 'wrap',
valign: 'middle',
font: 'times',
fontSize: 12,
overflow: 'linebreak'
},
headStyles: {
fillColor: [247, 185, 7]
},
theme: 'striped',
margin: {top: 150, right: 350},
didDrawPage: footer
});
first = pdf.autoTable.previous;
pdf.autoTable({
head: [[$frnt.find(".bk-title").text().trim().toString(), $frnt.find(".pgno").text().trim()]],
body: [[{content: $frnt.find(".title").text().trim().toString(), colSpan: 2, styles: {halign: 'justify'}}],
[{content: $frnt.find(".desc").text().trim().toString(), colSpan: 2, styles: {halign: 'justify'}}]],
startY: y,
styles: {
cellWidth: 'wrap',
valign: 'middle',
font: 'times',
fontSize: 12,
overflow: 'linebreak'
},
headStyles: {
fillColor: [247, 185, 7]
},
theme: 'striped',
margin: {top: 150, left: 340}
});
last = pdf.autoTable.previous;
if (typeof pdf.putTotalPages === 'function')
pdf.putTotalPages(totalPagesExp);
});
pdf.save(`${username}'s Notes.pdf`);
我该如何解决这个问题?
最后,我从here找到了解决方案。
这里 tables 是动态添加的。当页面上有多个 table 时,页脚会添加对应于每个 table。这就是页脚重叠的原因。基于上述解决方案,我将 footer()
函数的代码更改如下:
let currentpage = 0;
const footer = function (data) {
if (currentpage < pdf.internal.getNumberOfPages()) {
var imgData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGkAAABgCAYAAAAejVzyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEge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ozBHg89U6s5u5SLpvjobuaq+QdzXYvch5dVCFI37ENZKEOZ+cFYY/6eiwwnLAdyOnP9fFfRHNiICTkjzQ2Ml0Y8Wisn+4M91rwkJrwF5TXGBueBFom3PKUj03aYI/esdAUZDUXpNkhe5Lhxse40Oxsg1YMVNJdGL2hWS4TUlOhzlNeZe1C6QtKgICAs4ymusvcgzSKTQwno4U17j1Itch0TSmfKM7jWKSlpe5AqkVq8hhaYWI2XqRVmFpLzGHS/KGBL9SeaIgBLSSnW1piz7XpQ2pAioGuA3xjXKXPUiR5CU17SPF9mCpBc3hcdElNe0ixeZQtIQV9xUXtOuXtQGkv61fJTo1YAIL1HdliNepEPSvYZHvYYrr8k1LyL7vwADAHG5t/RI4Vz9AAAAAElFTkSuQmCC'
// HEADER
pdf.setFontSize(20);
pdf.setTextColor(40);
pdf.setFontStyle('normal');
if (imgData)
pdf.addImage(imgData, 'JPEG', 400, 30, 60, 60);
let str = 'Page ' + pdf.internal.getNumberOfPages();
if (typeof pdf.putTotalPages === 'function')
str = str + ' of ' + totalPagesExp;
pdf.setFontSize(10);
pdf.setFontStyle("normal");
pdf.text(str, data.settings.margin.left + 470, pdf.internal.pageSize.height - 30);
pdf.text(`© ${new Date().getFullYear()} 3d-reader.com All Rights Reserved.`, data.settings.margin.left, pdf.internal.pageSize.height - 30);
currentpage = pdf.internal.getNumberOfPages();
}
};