pdfh5在线预览pdf文件

前言

pc浏览器和ios的浏览器都可以直接在线显示pdf文件,但是android浏览器不能在线预览pdf文件,如何预览pdf文件?

Github: https://github.com/gjTool/pdfh5

Gitee: https://gitee.com/gjTool/pdfh5

使用pdfh5预览pdf

  1. 编写预览页面
html 复制代码
<html>
<head>
    <meta charset="UTF-8">
    <title>pdfh5预览</title>
    <link rel="stylesheet" href="pdfh5/css/pdfh5.css"/>
    <link rel="stylesheet" href="pdfh5/css/style.css"/>
    <style type="text/css">

    </style>
</head>
<body>
<div id="demo"></div>
</body>
<script src="pdfh5/js/pdf.js" type="text/javascript" charset="utf-8"></script>
<script src="pdfh5/js/pdf.worker.js" type="text/javascript" charset="utf-8"></script>
<script src="pdfh5/js/jquery-3.6.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="pdfh5/js/pdfh5.js" type="text/javascript" charset="utf-8"></script>
<script>
    var pdfh5 = new Pdfh5('#demo', {
        pdfurl: "./default.pdf" //可以是你的pdf链接地址/xxx/xxx.pdf
    });
</script>
</html>
  1. 下载需要用到的css和js文件
    https://github.com/gjTool/pdfh5

    请见Git仓库中寻找

  2. 访问网页测试

pdfh5 扩展API

https://gitee.com/gjTool/pdfh5#pdfh5js

遇到的问题

1. 显示页面高度很小,不正常显示

解决办法: 找到pdfh5.css, 屏蔽height属性

css 复制代码
.pdfjs .pdfViewer .pageContainer img {
    width: 100%;
    /*height: 100%;*/
    position: relative;
    z-index: 100;
	/* user-select:none; */
}
相关推荐
DanB242 小时前
html复习
javascript·microsoft·html
paid槮13 小时前
HTML5如何创建容器
前端·html·html5
拾光拾趣录14 小时前
HTML行内元素与块级元素
前端·css·html
精神小伙2号1 天前
css position
前端·css·html
鲸落✗1 天前
黑色风格音乐播放器网站模板(附完整源码)
前端·html·web
东华果汁哥1 天前
【URL 转换为PDF】HTML转换为PDF
前端·pdf·html
Tina学编程1 天前
HTML基础P1 | HTML基本元素
服务器·前端·html
山烛2 天前
小白学HTML,操作HTML网页篇(1)
运维·服务器·前端·python·html
GDAL2 天前
HTML 树结构(DOM)深入讲解教程
前端·html
蓝易云2 天前
精选HTML、JavaScript、ASP代码片段集锦
前端·后端·html