Я использую jsPDF на своем сайте для создания PDF файлов. Но теперь у меня есть несколько DIV для печати в одном PDF файле. которые могут занимать от 2 до 3 страниц.
Например:
<div id="part1">
content
</div>
<div id="part2">
content
</div>
<div id="part2">
content
</div>
мой код JS
- Это работает, но не так, как я ожидал. Он добавляет часть содержимого (которое не может быть включено в более чем одну страницу).
- Он удаляет теги html, такие как br, h1 и т.д.
function formtoPDF() {
jsPDF.API.mymethod = function() {
// 'this' will be ref to internal API object. see jsPDF source
// , so you can refer to built-in methods like so:
// this.line(....)
// this.text(....)
};
var doc = new jsPDF();
doc.mymethod();
var pdfPart1 = jQuery('#genPDFpart1');
var pdfPart2 = jQuery(".ltinerary");
var pdfPart3 = jQuery("#domElementHTML");
var specialElementHandlers = {
'#loadVar': function(element, renderer) {
return true;
}
};
doc.fromHTML(pdfPart1.html() + pdfPart3.html() + pdfPart3.html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.output('save', 'Download.pdf');
}
Могу ли я найти решение для этого. Спасибо заранее, приятели.