1.pdfobject.js官网:https://pdfobject.com/

2.在html文件中引入这个文件,以pdfobject.min.js为例

<script type="text/javascript" src="js/pdfobject.min.js"></script>

 效果1:在指定位置(当指定位置为全局时)浏览PDF,最终效果类似3.1,不做演示

<!DOCTYPE html>
<html>
   <head>
       <meta charset="UTF-8">
       <title>在指定div中浏览PDF</title>
       <!--在此引入bootstrap只为初始化样式div样式-->
       <link rel="stylesheet" href="css/bootstrap.min.css" />
       <style>
           /* 添加样式是为了实现全屏效果 */
           html,body{
               height: 100%;
               overflow: hidden;
           }
           
           #example1{
               height: 100%;
           }
           
           .pdfobject-container{
               /* height: 500px; */
           }
           
           .pdfobject{
               /* border: 1px solid #666; */
           }
       </style>
   </head>
   
   <body>
       <div id="example1"></div>
           
       <script type="text/javascript" src="js/pdfobject.min.js"></script>
       <script>
           // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf
           PDFObject.embed("pdf/Java.pdf", "#example1");
       </script>
   </body>
</html>

  

效果2:在指定位置(当指定位置为局部时)浏览PDF

<!DOCTYPE html>
<html>
   <head>
       <meta charset="UTF-8">
       <title>在指定div中浏览PDF</title>
       <!--在此引入bootstrap只为初始化样式div样式-->
       <link rel="stylesheet" href="css/bootstrap.min.css" />
       <style>
           html,body{
               height: 100%;
               overflow: hidden;
               /* 添加背景颜色是为了方便查看整个body范围 */
               background-color: cornflowerblue;
           }
           
           #example1{
               /* 设置放置PDF的div的样式 */
               height: 50%;
               width: 50%;
           }
           
           /* PDF容器样式 */
           .pdfobject-container{
               /* height: 500px; */
           }
           
           /* PDF样式 */
           .pdfobject{
               /* border: 1px solid #666; */
           }
       </style>
   </head>
   
   <body>
       <div id="example1"></div>
           
       <script type="text/javascript" src="js/pdfobject.min.js"></script>
       <script>
           // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf
           PDFObject.embed("pdf/Java.pdf", "#example1");
       </script>
   </body>
</html>

  

效果3:指定从多少页开始阅读(必须同时指定显示PDF的div)

<!DOCTYPE html>
<html>
   <head>
       <meta charset="UTF-8">
       <title>在指定div中浏览PDF</title>
       <!--在此引入bootstrap只为初始化样式div样式-->
       <link rel="stylesheet" href="css/bootstrap.min.css" />
       <style>
           /* 添加样式是为了实现全屏效果 */
           html,body{
               height: 100%;
               overflow: hidden;
           }
           
           #example1{
               height: 100%;
           }
           
           .pdfobject-container{
               /* height: 500px; */
           }
           
           .pdfobject{
               /* border: 1px solid #666; */
           }
       </style>
   </head>
   
   <body>
       <div id="example1"></div>
           
       <script type="text/javascript" src="js/pdfobject.min.js"></script>
       <script>
           // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf,指定PDF从20页开始阅读
           PDFObject.embed("pdf/Java.pdf", "#example1", {page: "20"});
       </script>
   </body>
</html>

  

原文地址:https://i.cnblogs.com/EditPosts.aspx?opt=1

 

使用pdfobject.js实现在线浏览PDF的更多相关文章

  1. java实现在线浏览PDF文档功能

    实现在线浏览pdf文档功能(本代码适用于项目服务中固定的并且少量的pdf浏览,比如注册时的注册条款在线浏览等): //设置响应内容类型为PDF类型 response.setContentType(&q ...

  2. https://github.com/Lushenggang/show-pdf在线浏览pdf文件在线浏览pdf文件

    在线浏览pdf文件 https://github.com/Lushenggang/show-pdf https://github.com/Lushenggang/show-pdf

  3. 在线浏览PDF之PDF.JS (附demo)

    平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html#skill 下载地址:http://mozilla.gith ...

  4. Asp.net MVC 利用(aspose+pdfobject.js) 实现在线预览word、excel、ppt、pdf文件

    在线预览word.excel.ppt利用aspose动态生成html 主要代码 private bool OfficeDocumentToHtml(string sourceDoc, string s ...

  5. 在线浏览pdf文件,pdfobject的简单使用

    该js插件,官网有详细的使用教程(网址:http://www.pdfobject.com/examples/).打开里面的例子后,查看新打开页面,打开并查看该页面的源代码. 需要的材料: 1.PDFo ...

  6. 基于ASP.NET MVC 利用(Aspose+Pdfobject.js) 实现在线预览Word、Excel、PPT、PDF文件

    #region VS2010版本以及以上版本源码下载地址:http://download.csdn.net/download/u012949335/10231812 VS2012版本以及以上版本源码下 ...

  7. 怎么用ABBYY在线浏览PDF文件

    ABBYY FineReader 让您可以从在线存储服务中打开图像或 PDF 文件,并将已识别文本保存至在线存储服务中,如 Dropbox.SkyDrive 或 Google Drive 等.通过在 ...

  8. vue 中PDF实现在线浏览,禁止下载,打印

    需求:在线浏览pdf文件,并且禁止掉用户下载打印的效果. 分析:普通的iframe.embed标签都只能实现在线浏览pdf的功能,无法禁止掉工具栏的下载打印功能.只能尝试使用插件,pdfobject. ...

  9. 在线打开,浏览PDF文件的各种方式及各种pdf插件------(MS OneDrive/google drive & google doc/ github ?raw=true)

    在线打开,浏览PDF文件的各种方式: 1 Google drive&doc   (国内不好使,you know GFW=Great Firewall) 1. google drive: 直接分 ...

随机推荐

  1. ESP8266-12F 中断

    外部中断: 基于ESP8266的NodeMcu的数字IO的中断功能是通过attachInterrupt,detachInterrupt函数所支持的.除了D0/GPIO16,中断可以绑定到任意GPIO的 ...

  2. Python---进阶---logging---logger

    一.####用logging的四大组件来实现日志的功能 - 打印出函数执行的时间,日志的等级,日志的消息 - 用装饰器 - 不同的日志,要记录不同等级的日志消息 ------------------- ...

  3. SSM图片

    非关系型数据,redis,mongoDB关系型数据,mysql,oracle 1.springmvc+spring+mybatis1.导入jar2.书写配置xml(applicationContext ...

  4. 多线程之同时更改数据问题--启用lock

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. php shuffle()函数 语法

    php shuffle()函数 语法 作用:把数组中的元素按随机顺序重新排序:富瑞华 语法:shuffle(array) 参数: 参数 描述 array 必需.规定要使用的数组. 说明:若成功则返回 ...

  6. Deque 容器

    1.Deque (1)定义 deque容器是C++标准模版库(STL,Standard Template Library)中的部分内容.deque容器类与vector类似,支持随机访问和快速插入删除, ...

  7. Internet History, Technology, and Security(week5)——Technology: Internets and Packets

    前言: 之前都在学习Internet的历史,从这周开始,进入到了Internet技术的学习. Layer1: Link Introduction / The Link Layer 80年代之前,主流网 ...

  8. 【转】Django框架请求生命周期

    https://www.cnblogs.com/gaoya666/p/9100626.html 先看一张图吧! 1.请求生命周期 - wsgi, 他就是socket服务端,用于接收用户请求并将请求进行 ...

  9. SQL字串截取函数编写及应用

    SQL里面一种用来截取字符串的方法,用的是表函数实现字符串截取并应用的SQL操作语句中. .截取字符串表函数 ALTER FUNCTION [dbo].[SplitToTable] ( -- Add ...

  10. 170815-关于Filter的知识点

    Filter简介:         Filter翻译为中文是过滤器的意思.         Filter是JavaWeb的三大web组件之一:Servlet.Filter.Listener       ...