我如何在不重写每一页的所有内容的情况下将以jspdf-object创建的数据重用到同一pdf文档中的其他页面?我也只需要在每一页上调整一行。以下是Se评论。
$("#pdfBtn").on('click', function(){
var doc = new jsPDF();
doc.text(5, 5, 'Specific text for page 1');
// Reusable data
doc.text(5, 10, 'This is reusable text');
doc.text(5, 15, 'More reusable text');
doc.addPage();
doc.text(5, 5, 'Specific text for page 2');
// Here i want to reuse the data from page 1
doc.addPage();
doc.text(5, 10, 'Specific text for page 3');
// Here i want to reuse the data from page 1
});
答案 0 :(得分:0)
找到了解决方案。只需创建一个包含数据的函数,然后在每个新页面中调用它即可。
Stream<int> debounce(
Stream<int> source, Duration limit, int combine(int a, int b)) async* {
int prev;
var stopwatch;
await for (var event in source) {
if (stopwatch == null) {
// First event.
prev = event;
stopwatch = Stopwatch()..start();
} else {
if (stopwatch.elapsed < limit) {
prev = combine(prev, event);
} else {
yield prev;
prev = event;
}
stopwatch.reset();
}
}
// If any event, yield prev.
if (stopwatch != null) yield prev;
}