| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
- <title>PDF预览</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- height: 100vh;
- overflow: hidden;
- background-color: #FFFFFF;
- }
- #pdf-container {
- width: 100%;
- height: 100%;
- }
- .loading {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- font-size: 14px;
- color: #666;
- }
- </style>
- </head>
- <body>
- <div id="pdf-container"></div>
- <div class="loading" id="loading">加载中...</div>
- <script src="js/pdfh5.js"></script>
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- var urlParams = new URLSearchParams(window.location.search);
- var pdfUrl = urlParams.get('url');
-
- if (!pdfUrl) {
- document.getElementById('loading').textContent = '未找到PDF文件';
- return;
- }
-
- var container = document.getElementById('pdf-container');
- var pdfh5 = new Pdfh5(container, {
- pdfurl: decodeURIComponent(pdfUrl),
- zoomScale: [0.5, 2],
- maxZoom: 2,
- minZoom: 0.5,
- showZoom: false,
- showFullScreen: false,
- showRotate: false,
- showProgress: true,
- progressBar: true,
- progressBarColor: '#2E64FA',
- renderType: 'canvas',
- curNumMode: 'number',
- lazy: true,
- withCredentials: true
- });
-
- pdfh5.on('complete', function(status, msg, time) {
- document.getElementById('loading').style.display = 'none';
- if (status === 'error') {
- console.error('PDF加载失败:', msg);
- }
- });
-
- pdfh5.on('error', function(error) {
- document.getElementById('loading').style.display = 'none';
- console.error('PDF加载错误:', error);
- });
- });
- </script>
- </body>
- </html>
|