下载pdf.js
官网地址
https://mozilla.github.io/pdf.js/
在这里插入图片描述

php代码

//转义两次php把中文字转义
$title =iconv("utf-8","gbk",urlencode(urlencode($info['pdf_name'])));
$url=request()->domain();
$code_content = $url.'/static/pdf/web/viewer.html?file=/static/uploads/'.$info['pdf'].'&dow='.$url.'/static/uploads/'.$info['spdf'].'&title='.$title;

js

//接受url的参数
function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        var strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
        theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
        }
        }
        return theRequest;
    }
    //在viewer.js中function download方法
    //转义传过来的下载名
var filename = decodeURIComponent(arr.tit);
GitHub 加速计划 / pd / pdf.js
47.48 K
9.86 K
下载
PDF Reader in JavaScript
最近提交(Master分支:2 个月前 )
18284815 [Editor] Update the disclaimer string in the new alt-text dialog (bug 1911738) 2 个月前
fc602c65 And tweak the css in order to take into account that disclaimer can be on two (or more lines). 2 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐