如何在jspdf中将pdf分割成多个页面 [英] How to split pdf into multiple pages in jspdf
本文介绍了如何在jspdf中将pdf分割成多个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用JSPDF将我的div的内容捕获到pdf中。
并非我的div的所有内容都进入pdf而不是一个页面。
div可能包含多个pdf的数据。
以下是我的代码---
Hi ,
I am trying to capture contents of my div into a pdf using JSPDF.
Not all the contents of my div are coming into the pdf beyond one page .
The div may contain data for more than one pdf .
Below is my code ---
$(document).ready(function () {
createPDF();
$('.mydiv').css('display', 'none');
});
function createPDF() {
var
form = $('.mydiv'),
cache_width = form.width(),
a4 = [595.28, 841.89];
getCanvas().then(function (canvas) {
var
img = canvas.toDataURL("image/png"),
doc = new jsPDF({
unit: 'px',
format: 'a4'
});
doc.addImage(img, 'JPEG', 20, 20);
doc.save('spmepdf.pdf');
form.width(cache_width);
window.location.href = '@Url.Action("Landing")';
});
};
// create canvas object
function getCanvas() {
var
form = $('.mydiv'),
cache_width = form.width(),
a4 = [595.28, 841.89];
debugger
form.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
return html2canvas(form, {
imageTimeout: 2000,
removeContainer: true
});
};
我尝试过:
我尝试使用pagesplit选项但没有成功。请帮助我
What I have tried:
I tried using pagesplit option but no success . PLease help me
推荐答案
(document).ready(function(){
createPDF();
(document).ready(function () { createPDF();
( '.mydiv')。css('display','none');
});
函数createPDF(){$ b $ b var
form =
('.mydiv').css('display', 'none'); }); function createPDF() { var form =
('。mydiv'),
cache_width = form.width(),
a4 = [595.28,841.89];
getCanvas()。then(function(canvas){
var
img = canvas.toDataURL(image / png),
doc = new jsPDF({
单位:'px',
格式:'a4'
});
doc.addImage(img,'JPEG',20,20);
doc.save('spmepdf.pdf');
form.width(cache_width);
window.location.href ='@ Url.Action(Landing)';
}) ;
};
//创建画布对象
函数getCanvas(){
var
form =
('.mydiv'), cache_width = form.width(), a4 = [595.28, 841.89]; getCanvas().then(function (canvas) { var img = canvas.toDataURL("image/png"), doc = new jsPDF({ unit: 'px', format: 'a4' }); doc.addImage(img, 'JPEG', 20, 20); doc.save('spmepdf.pdf'); form.width(cache_width); window.location.href = '@Url.Action("Landing")'; }); }; // create canvas object function getCanvas() { var form =
这篇关于如何在jspdf中将pdf分割成多个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文