Commit 0726ade8 authored by 李苏's avatar 李苏 💬

dp

parent c989632e
function fullScreen(element) {
const elem = element || document.documentElement;
if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.requestFullScreen) {
elem.requestFullscreen();
} else if (elem.msExitFullscreen) {
elem.msExitFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
//退出全屏
function exitFullscreen() {
var de = document;
if (de.exitFullscreen) {
de.exitFullscreen();
} else if (de.mozCancelFullScreen) {
de.mozCancelFullScreen();
} else if (de.webkitCancelFullScreen) {de.webkitCancelFullScreen();
}
}
function dbenlarge(domid,isTrue) {
let is=isTrue
document.getElementById(domid).style.backgroundColor="#FFFFFF"
document.getElementById(domid).addEventListener('dblclick', function(e) {
fullScreen(document.getElementById(domid));
}, false);
if(isTrue){
fullScreen(document.getElementById(domid));
}
}
var pdfshow=function(url,domid,time){
return new Promise(function(r,n){
let timenum
let pdfobj=pdfjsLib.getDocument(url)
let canvas=document.getElementById(domid);
pdfobj.promise.then(function(pdf){
let nowpage=0
let numPages=pdf._pdfInfo.numPages
timenum=setInterval(function(){
if(nowpage<numPages){
nowpage++
}else{
nowpage=1
}
pdf.getPage(nowpage).then(function(page) {
// 设置渲染属性
let viewport = page.getViewport({ scale: 2});
canvas.height = viewport.height;
canvas.width = viewport.width;
let outputScale = 1;
let context = canvas.getContext('2d');
let transform = outputScale !== 1
? [outputScale, 0, 0, outputScale, 0, 0]
: null;
let renderContext = {
canvasContext: context,
transform: transform,
viewport: viewport
};
page.render(renderContext);
});
},time)
r(timenum)
})
})
}
/* 封装pdf
url:pdf地址
domid:canvas id
time:跳页时间(ms)
.then((e)=>{获取定时器})
*/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment