å端使ç¨pdf.jsé¢è§pdfæ件_gwj_20200323_180012
å端使ç¨pdf.jsé¢è§pdfæ件_gwj_20200323_180012
æ¬demoä½è
ä¿¡æ¯:
å±±ä¸ææ¡¥æºè½ç§ææéå
¬å¸ http://www.yiqiao.net.cn
HttpPrinter-ç½é¡µæå°æ件 http://www.HttpPrinter.com
æ¬demoä¸è½½å°å: https://www.lanzous.com/iakhzob
layerä¸è½½å°å http://layer.layui.com/
æ使ç¨ççæ¬æ¯ layer-v3.1.1
PDF.jså¯å¨å®ç½ä¸è½½ å°åï¼http://mozilla.github.io/pdf.js/
æ使ç¨ççæ¬æ¯ pdfjs-2.4.456
å¨webç®å½ä¸æviewer.jsæ件
第ä¸æ¥:
3494
value: "compressed.tracemonkey-pldi-09.pdf",
æ¹ä¸º (好åä¸è¯¥ä¹æ²¡å
³ç³»)
value: "",
第äºæ¥:
1731è¡ ç¦ç¨ä¸ä¸ å ± 3è¡,ç®çæ¯ ç¦ç¨åå¯ä»¥è·¨å
//if (origin !== viewerOrigin && protocol !== "blob:") {
// throw new Error("file origin does not match viewer's");
//}
使ç¨æ¹æ³1 :
å¨æé®ç¹å»äºä»¶ä¸è°ç¨window.open()
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name=referrer content=never>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="renderer" content="webkit">
</head>
<body>
<button οnclick="preview()">PDFé¢è§</button>
</body>
<script>
function preview() {
console.log('test');
var pdf = 'pdfçURL';
window.open('./js/pdf/web/viewer.html?file=' + pdf, 'PDF');
}
</script>
</html>
使ç¨æ¹æ³äº:
layer å¼¹åºpdfæ件
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name=referrer content=never>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="renderer" content="webkit">
<script src="http://cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
<script src="js/layer/layer.js"></script>
</head>
<body>
<button οnclick="preview()">PDFé¢è§</button>
</body>
<script>
function preview() {
console.log('test');
//var pdf = 'https://axhl-test-1252661357.cos.ap-shanghai.myqcloud.com/pdf/1536742627489-310270d9-4e12-2640-8cb6-cfc07a6f6d1b.pdf';
var pdf = '../../../example2.pdf';
//var pdf = 'http://localhost/pdfjs2/pdfjs_gwj/example1.pdf';
var htmlurl = './js/pdf/web/viewer.html?file=' + pdf;
layer.open({
type: 2,
title: '欢è¿é¡µ',
maxmin: true,
area: ['800px', '500px'],
content: htmlurl,
//content: 'http://layer.layui.com/test/welcome.html',
end: function(){
layer.tips('Hi', '#about', {tips: 1})
}
});
}
</script>
</html>
æå°ææ