|
pdfViewer(pdf阅读器)demo分享
[复制链接]
pdfViewer 封装了一个简单的 pdf 阅读器,本模块只支持阅读 pdf 格式的文档,本模块支持对网络 pdf 文件的阅读,当传入一个网络路径,模块内部会先下载文件到本地缓存文件,然后再打开读取。用户再次打开相同路径的网络文件时,则先读取缓存在本地的文件。
运行图如下:
前端示例代码如下:
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
- <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
- <title>WinA</title>
- <link rel="stylesheet" type="text/css" href="css/api.css" />
- <link rel="stylesheet" type="text/css" href="css/box.css" />
- <script type="text/javascript" src="script/public.js"></script>
- <style>
- p{
- color:#999;
- padding:5px;
- }
- #main{
- text-align:center;
- padding-top:550px;
- }
- #main button{
- width:280px;
- margin-bottom:10px;
- }
- </style>
- <script type="text/javascript">
-
- var demo = null;
- apiready = function(){
- demo = api.require('pdfViewer');
- }
- function openView(){
- var param = {
- msg:"Hello APICloud!",
- path:"http://myemail**.**/res/swift.pdf",
- rect:{x:5,y:50,w:api.winWidth-2,h:500}
- };
- console.log(demo.openView);
- demo.openView(param, function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- function preView(){
- var param={bgColor:'#ff0000'}
- demo.preView(param,function(ret,err){})
- }
- function category(){
- demo.category(function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- function showView(){
- demo.showView(function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- function hideView(){
- demo.hideView(function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- function clearCache(){
- demo.clearCache(function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- function closeView(){
- demo.closeView(function(ret, err){
- console.log(JSON.stringify(ret));
- });
- }
-
- </script>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <button onclick="openView()" >openView()</button><br>
- <button onclick="preView()" >preView()</button><br>
- <button onclick="category()" >category()</button><br>
- <button onclick="clearCache()" >clearCache()</button><br>
- <button onclick="showView()" >showView()</button><br>
- <button onclick="hideView()" >hideView()</button><br>
- <button onclick="closeView()" >closeView()</button><br>
-
- </div>
- </div>
- </body>
- </html>
复制代码
如有问题,欢迎在下方留言讨论,谢谢支持。
|
本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册
X
|