所以,我实际上有这个功能。用下面的JS。问题出在提交时,下一页不应反映这些更改,而是 ONLY 反映在生成的PDF中。目前正在正确生成PDF,但第二页或第二个视图(PDF中生成的内容显示在当前)不应该是这种情况,此静态页面应保持原样并且只能在生成的PDF。
这实际上是原始问题 - 虽然范围已转换为当前问题提示新问题,但URL可用于示例目的,因为它可能有所帮助。 insert custom HTML content to checkbox containers of items 'checked'
texts = {
item1: 'Item Box 1 Content <strong>html</strong> right here!',
item2: 'Now its Item Box 2 <strong>html</strong> content here !',
item3: 'This is the example <strong>html</strong> of Item box 4!',
item4: 'Item box number 5 <strong>html</strong> content is here!',
}
$("#container").css('background', '#fff')
$('.download-pdf').click(function() {
notChecked = $("input[type=checkbox]:not(:checked)").parent();
notChecked.hide();
yesChecked = $("input[type=checkbox]:checked").parent();
$.each(yesChecked, function( index, el ) {
$(el).show().html(texts[$(el).attr('id')]);
});
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(document.getElementById('records'), function() {
// add here
});
var file = 'test';
if (typeof doc !== 'undefined') {
doc.save(file + '.pdf');
} else if (typeof pdf !== 'undefined') {
setTimeout(function() {
pdf.save(file + '.pdf');
// $("#item4").hide();
}, 2000);
} else {
alert('Error 0xE001BADF');
}
});
尝试:
var pdf = new jsPDF('p', 'pt', 'a4'); // moved everything relevant to be called within jsPDF object here
pdf.addHTML(document.getElementById('records'), function() {
// add here
texts = {
item1: 'Item Box 1 Content <strong>html</strong> right here!',
item2: 'Now its Item Box 2 <strong>html</strong> content here !',
item3: 'This is the example <strong>html</strong> of Item box 4!',
item4: 'Item box number 5 <strong>html</strong> content is here!',
}
notChecked = $("input[type=checkbox]:not(:checked)").parent();
notChecked.hide();
yesChecked = $("input[type=checkbox]:checked").parent();
$.each(yesChecked, function( index, el ) {
$(el).show().html(texts[$(el).attr('id')]);
});
});