首先下载pdf.js插件,放到项目里面
官网下载地址:http://mozilla.github.io/pdf.js/getting_started/#download
在页面引入pdf.js,然后进行下图操作
<button onclick="prepdf()">预览</button>
<script src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="~/Content/pdf/build/pdf.js"></script>
<script>
function prepdf() {
var file = "/Content/测试.pdf"
window.open("/Content/pdf/web/viewer.html?file=" + file);
}
</script>
效果如下: