jspdf 检查pdf文件大小
jspdf Checking pdf file size
我想用 jspdf.js 脚本检查 pdf 文件的大小。我需要在下载文件之前在屏幕上显示它。有没有可能?
function demoFromHTML(x = false) {
var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#print')[0];
specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},
function (dispose) {
if(x){
pdf.output('dataurlnewwindow');
}else{
pdf.save('<?php the_title() ?>.pdf');
}
}, margins
);
}
我找到了解决办法,很简单。
也许有人会用它:
pdf.output().length;
测试一下:
pdf.output('datauristring').length
对我有用
我想用 jspdf.js 脚本检查 pdf 文件的大小。我需要在下载文件之前在屏幕上显示它。有没有可能?
function demoFromHTML(x = false) {
var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#print')[0];
specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(
source,
margins.left,
margins.top, {
'width': margins.width,
'elementHandlers': specialElementHandlers
},
function (dispose) {
if(x){
pdf.output('dataurlnewwindow');
}else{
pdf.save('<?php the_title() ?>.pdf');
}
}, margins
);
}
我找到了解决办法,很简单。 也许有人会用它:
pdf.output().length;
测试一下:
pdf.output('datauristring').length
对我有用