如何预渲染例如在pdf.js中滚动文档时是2页而不是一页?
我相信它与下面的代码部分有关,但是我根本不具备编辑它的知识,因此它可以预先渲染多个页面。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0033)http://gw.hallaencom.com/UI/_EDMS -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=edge">
<style>
table tr td{
border: 1px solid;
}
/*css search*/
.searchBar {
margin-right: 20px;
display: flex;
justify-content: flex-end;
margin-top: 10px;
}
#modeUser {
padding-right: 6px;
}
#btnSearch {
background-color: #267bcd;
color: white;
border: solid 1px #267bcd;
}
.btn_w {
border-radius: 3px;
font-size: 12px;
border: solid 1px #bebebe;
padding: 6px 9px;
margin: 0 2px;
}
#tbSearch {
width: 98px;
}
select::-ms-expand {
display: none;
background-image: url(data:image/svg+xml;base64,PHN2ZyBmaWxsPSdibGFjaycgaGVpZ2h0PScyNCcgdmlld0JveD0nMCAwIDI0IDI0JyB3aWR0aD0nMjQnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PHBhdGggZD0nTTcgMTBsNSA1IDUtNXonLz48cGF0aCBkPSdNMCAwaDI0djI0SDB6JyBmaWxsPSdub25lJy8+PC9zdmc+);
}
select, .msandsafa {
box-shadow: none;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
background: transparent;
background-image: url(data:image/svg+xml;base64,PHN2ZyBmaWxsPSdibGFjaycgaGVpZ2h0PScyNCcgdmlld0JveD0nMCAwIDI0IDI0JyB3aWR0aD0nMjQnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PHBhdGggZD0nTTcgMTBsNSA1IDUtNXonLz48cGF0aCBkPSdNMCAwaDI0djI0SDB6JyBmaWxsPSdub25lJy8+PC9zdmc+);
background-repeat: no-repeat;
background-position-x: 44px;
background-position-y: 50%;
border: solid 1px #ccc;
width: 66px;
}
</style>
</head>
<body oncontextmenu="return false">
<input style="width:100%" type="text">
<div>
<div class="searchBar">
<select id="modeUser" class="btn_w" name="modeUser">
<option value="0">이름</option>
<option value="1">아이디</option>
</select>
<input id="tbSearch" name="tbSearch" type="text" class="tb_m btn_w" style="" value="">
<input type="button" id="btnSearch" class="btn_w" value="검색">
</div>
</body>
</html>
}
之所以这样,是因为我自定义了pdf.js,以同时显示2页,而不是一页(有点像一本书)。为使此方法最佳运行,最好在更改页面时预渲染接下来的2页,而不必等待其中的一页加载。
我尝试添加另一个承诺并将renderPages: function renderPages() {
var _this = this;
var pageCount = this.pagesOverview.length;
var renderNextPage = function renderNextPage(resolve, reject) {
_this.throwIfInactive();
if (++_this.currentPage >= pageCount) {
renderProgress(pageCount, pageCount, _this.l10n);
resolve();
return;
}
var index = _this.currentPage;
renderProgress(index, pageCount, _this.l10n);
renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
renderNextPage(resolve, reject);
}, reject);
};
return new Promise(renderNextPage);
修改为index + 1
,但这没什么区别。
我很清楚,这段代码对较大的视图没有帮助/对于不使用pdf.js的开发人员来说,但是我希望对pdf.js有所了解的人可以提供帮助。