touchpdf 中文API
下载地址: http://github.com/loicminghetti/touchpdf/archive/master.zip
一款在手机端 阅读pdf 文件的 js库,能够 通过滑动进行 pdf 预览 翻页
TouchPDF是一个jQuery插件,它使用pdf.js短语和呈现支持触摸手势和自动页面选项卡的Web PDF查看器。
依赖关系:
- PDF.js
- jQuery touchSwipe插件
- jQuery panzoom插件
- jQuery mousewheel插件
特征:
PDF可以使用滚动,两个手指捏,+/-键和工具栏按钮进行缩放。
PDF可以使用一根手指刷。
在文档顶部的工具栏,标题,页码和下一页/上一页和缩放的按钮。
如何使用它:
1.将jQuery TouchPDF的CSS文件加载到文档的头部。
<link href="jquery.touchPDF.css" rel="stylesheet">
2.在文档末尾加载jQuery库,jQuery TouchPDF插件和其他必需的资源。
<script src="pdf.compatibility.js"></script>
<script src="pdf.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="jquery.touchSwipe.min.js"></script>
<script src="jquery.touchPDF.js"></script>
<script src="jquery.panzoom.js"></script>
<script src="jquery.mousewheel.js"></script>
3.为Web PDF查看器创建一个DOM元素。
<div id="myPDF"></div>
4.初始化插件并指定要在DOM元素中显示的PDF文件的路径。
$(function() {
$("#myPDF").pdf( {
source: "demo.pdf",
// MORE SETTINGS HERE
} );
});
5.插件参数设置
// Path of PDF file to display
source: null,
// Title of the PDF to be displayed in the toolbar
title: "TouchPDF",
// Array of tabs to display on the side.
tabs: [],
// Default background color for all tabs.
// Available colors are "green", "yellow", "orange", "brown",
// "blue", "white", "black" and you can define your own colors with CSS.
tabsColor: "beige",
// Disable zooming of PDF document.
disable<a href="http://www.jqueryscript.net/zoom/">Zoom</a>: false,
// Disable swipe to next/prev page of PDF document.
disableSwipe: false,
// Disable all internal and external links on PDF document
disableLinks: false,
// Disable the arrow keys for next/previous page and +/- for zooming
disableKeys: false,
// Force resize of PDF viewer on window resize
redrawOnWindowResize: true,
// Show a toolbar on top of the document with title,
// page number and buttons for next/prev pages and zooming
showToolbar: true,
// A handler triggered when PDF document is loaded
loaded: null,
// A handler triggered each time a new page is displayed
changed: null,
// Text or HTML displayed on white page shown before document is loaded
loadingHeight: 841,
// Height in px of white page shown before document is loaded
loadingWidth: 595,
// Width in px of white page shown before document is loaded
loadingHTML: "Loading PDF"