pdf在线浏览器pdf viewer

有的时候为了pdf保密的需求需要将pdf转换为图片的形式在网页上展示出来,所以经常需要这样的pdf页面浏览器,这里发现了一个可以将pdf文件实时的转换为图片并在网页端展示的项目,其中只需要用到前端js和html文件既可以实现pdf文件的在线预览,实时展示。用户只能看到高清图片,

无法复制保存具体的内容。

具体效果图下

 在线demo地址

index.html

<!DOCTYPE html>
<!--[if IEMobile 7 ]>    <html class="no-js iem7"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"> <!--<![endif]-->
  <head>
    <meta charset="utf-8">
    <title>Bootstrap PDF Viewer</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="cleartype" content="on">

    <!-- For iOS web apps. Delete if not needed. https://github.com/h5bp/mobile-boilerplate/issues/94 -->    
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="">
    
    <!-- Twitter Bootstrap -->
    <link rel="stylesheet" href="lib/twitter-bootstrap/css/bootstrap.css">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">

    <!-- Bootstrap PDF Viewer -->
    <link rel="stylesheet" href="css/bootstrap-pdf-viewer.css">
  </head>
  <body>

    <!-- Bootstrap PDF Viewer -->
    <div id="viewer" class="pdf-viewer" data-url="sample.pdf"></div>

    <!-- jQuery -->
    <script src="lib/jquery-1.9.1.js"></script>

    <!-- Twitter Bootstrap -->
    <script src="lib/twitter-bootstrap/js/bootstrap.js"></script>

    <!-- Bootstrap PDF Viewer -->
    <script src="lib/pdf.js"></script>
    <script src="js/bootstrap-pdf-viewer.js"></script>

    <script>
      var viewer;

      $(function() {
        viewer = new PDFViewer($('#viewer'));
      });
    </script>
  </body>
</html>

|--bootstrap-pdf-viewer-master/
|  +--.gitignore
|  +--21009165554.png
|  |--css/
|  |  +--bootstrap-pdf-form-builder.css
|  |  +--bootstrap-pdf-form-viewer.css
|  |  +--bootstrap-pdf-viewer.css
|  |--data/
|  |  +--form.json
|  |  +--submission.json
|  +--form-builder.html
|  +--form-viewer.html
|  +--form.pdf
|  +--index.html
|  |--js/
|  |  +--bootstrap-pdf-form-builder.js
|  |  +--bootstrap-pdf-form-common.js
|  |  +--bootstrap-pdf-form-viewer.js
|  |  +--bootstrap-pdf-viewer.js
|  |--lib/
|  |  |--font-awesome/
|  |  |  |--css/
|  |  |  |  +--font-awesome-ie7.css
|  |  |  |  +--font-awesome-ie7.min.css
|  |  |  |  +--font-awesome.css
|  |  |  |  +--font-awesome.min.css
|  |  |  |--font/
|  |  |  |  +--fontawesome-webfont.eot
|  |  |  |  +--fontawesome-webfont.svg
|  |  |  |  +--fontawesome-webfont.ttf
|  |  |  |  +--fontawesome-webfont.woff
|  |  |  |  +--FontAwesome.otf
|  |  |  |--less/
|  |  |  |  +--bootstrap.less
|  |  |  |  +--core.less
|  |  |  |  +--extras.less
|  |  |  |  +--font-awesome-ie7.less
|  |  |  |  +--font-awesome.less
|  |  |  |  +--icons.less
|  |  |  |  +--mixins.less
|  |  |  |  +--path.less
|  |  |  |  +--variables.less
|  |  +--jquery-1.9.1.js
|  |  +--pdf.js
|  |  |--twitter-bootstrap/
|  |  |  |--css/
|  |  |  |  +--bootstrap.css
|  |  |  |  +--bootstrap.min.css
|  |  |  |--js/
|  |  |  |  +--bootstrap.js
|  |  |  |  +--bootstrap.min.js
|  +--README.md
|  +--sample.pdf

文件有点多,不便一一列举。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PDFViewer是一种用于显示PDF文档的工具或应用程序。大多数PDFViewer应用程序提供基本的阅读和浏览功能,例如放大缩小、翻页、搜索、书签、注释等。一些高级PDFViewer应用程序还提供了更多的功能,例如插入图片、旋转页面、添加水印等。 在iOS开发中,可以使用CoreGraphics框架和CGPDFDocument类来实现PDFViewer。以下是基本的步骤: 1. 获取PDF文件路径 ``` NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"your_pdf_file_name" ofType:@"pdf"]; ``` 2. 创建CGPDFDocument对象 ``` CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:pdfPath]); ``` 3. 获取PDF文件的页数 ``` NSInteger numberOfPages = CGPDFDocumentGetNumberOfPages(pdfDocument); ``` 4. 构建PDFViewer界面 可以使用UIScrollView或UICollectionView来实现PDFViewer界面,每个子视图代表一个页面。 5. 绘制PDF页面 在UIScrollView或UICollectionView的子视图中,可以使用CoreGraphics框架的绘图函数来绘制PDF页面。 ``` CGContextRef context = UIGraphicsGetCurrentContext(); CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDocument, pageIndex); CGContextSaveGState(context); CGContextScaleCTM(context, scale, scale); CGContextTranslateCTM(context, -pageRect.origin.x, -pageRect.origin.y); CGContextDrawPDFPage(context, pdfPage); CGContextRestoreGState(context); ``` 6. 实现滑动翻页功能 可以使用UIScrollView或UICollectionView的滚动事件来实现滑动翻页功能。 注意:在使用完CGPDFDocument后,需要释放资源。 ``` CGPDFDocumentRelease(pdfDocument); ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值