try, try nothing

pull/578/head^2
qkqpttgf 2022-04-16 10:51:43 +08:00 committed by GitHub
parent 9c8c739a9c
commit a4d0d8dfff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 1 deletions

View File

@ -665,6 +665,21 @@
disableAutoFetch: true,
rangeChunkSize: 65535
});
/*loadingTask.onProgress = (e) => {
//console.log(e);
var p = document.getElementById('p');
if (p==null) {
p = document.createElement('div');
p.id = 'p';
p.setAttribute('onclick', "this.style.display = 'none';");
p.style = 'left: 10px; top: 30%; position: fixed;';
document.body.appendChild(p);
}
p.innerHTML = 'Loaded: ' + ((e.loaded/e.total)*100).toFixed(2) + '%<br>(' + size_format(e.loaded) + ' / ' + size_format(e.total) + ')';
p.style.display = '';
if (e.loaded==e.total) p.style.display = 'none';
}*/
loadingTask.promise.then(function(pdf) {
var pagenum = pdf.numPages;
var pdfContainer = document.getElementById('pdf-d');
@ -678,7 +693,6 @@
pdfContainer.appendChild(pdfnextpagebutton);
var pdfWaitNextPage = setInterval(function(){
//console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight);
console.log("next page: " + pagepos + " / " + pagenum);
if (pdfnextpagebutton.style.display=='none') {
for (var i=pagepos;i<=(pagepos+4<pagenum?pagepos+4:pagenum);i++) {
var canvasNew = document.createElement('canvas');
@ -688,6 +702,7 @@
}
pagepos = i;
if (pagepos<pagenum) {
console.log("next page: " + pagepos + " / " + pagenum);
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
pdfnextpagebutton.style.display ='';
pdfContainer.appendChild(pdfnextpagebutton);
@ -713,6 +728,24 @@
page.render(renderContext);
});
}
function size_format(num) {
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' B';
}
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' KB';
}
if (num>1024) {
num=num/1024;
} else {
return num.toFixed(2) + ' MB';
}
return num.toFixed(2) + ' GB';
}
<!--IspdfFileEnd-->
<!--IsFileEnd-->
<!--IsFolderStart-->