javascript - 对象 PDF 查看器无法在 chrome 中呈现超过 2.0 MB 的大文件
问题描述
抱歉,如果之前可能有人问过这个问题,但我试图在上传之前显示 pdf 文档的预览,并且仅适用于小于 1Mb 数据的 pdf。上面的任何数据似乎都没有显示在我的浏览器中。我正在使用铬。这是我的 XHTML 代码,它适用于小于 1MB 的 pdf 文件。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
<script type="text/javascript">
//<![CDATA[
function renderPDF(input)
{
if (input.files && input.files[0])
{
var reader = new FileReader();
reader.onload = function (e)
{
$('#p_viewer').attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
//]]>
</script>
</h:head>
<h:body>
<div class="row">
<div class="col-md-4">
<h:form id="uploader_form" enctype="multipart/form-data">
<h:inputFile value="#{up.file}" onchange="renderPDF(this)" />
</h:form>
</div>
<div class="col-md-8">
<p:outputPanel id="out">
<iframe frameborder="0" height="600" width="100%" id="p_viewer" type="application/pdf">
</iframe>
</p:outputPanel>
</div>
</div>
</h:body>
</html>
或者在单击上传提交按钮之前是否有另一种方法可以在 JSF 中显示 pdf 文档?
解决方案
推荐阅读
- python - Model 类和模型功能 API 的子类化在 tensorflow 中给出不同的结果
- angular - 无法使用 Angular 应用程序为树莓派创建 docker 映像
- javascript - 可以从 txt 文件中绘制值的 Javascript 图表
- sql - 如何在 oracle db 中构造日期?
- javascript - 基于布尔变量的条件路由
- python - AttributeError:模块“gspread”没有属性“open_by_key”
- batch-file - 用于识别丢失的数字文件名的批处理脚本
- winapi - 如何设置 GroupBox 的标题颜色?
- python - RaspberryPi Shell 在 Python-Curses (Ctrl-C) 后冻结
- javascript - 为什么我的两个值没有正确比较?