Merge pull request #317 from zzzhouuu/master

feat: 通过配置控制PDF.js viewer toolbar & secondaryToolbar功能按钮
This commit is contained in:
gitchenjh
2021-12-10 17:31:25 +08:00
committed by GitHub
6 changed files with 117 additions and 9 deletions

View File

@ -2240,13 +2240,21 @@ function reportPageStatsPDFBug({
}
function webViewerInitialized() {
const appConfig = PDFViewerApplication.appConfig;
let file;
let disableDownload;
const queryString = document.location.search.substring(1);
const params = (0, _ui_utils.parseQueryString)(queryString);
var appConfig = PDFViewerApplication.appConfig;
var file;
var disablePresentationMode;
var disableOpenFile;
var disablePrint;
var disableDownload;
var disableBookmark;
var queryString = document.location.search.substring(1);
var params = (0, _ui_utils.parseQueryString)(queryString);
file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
disablePresentationMode = 'disablepresentationmode' in params ? params.disablepresentationmode : 'false';
disableOpenFile = 'disableopenfile' in params ? params.disableopenfile : 'false';
disablePrint = 'disableprint' in params ? params.disableprint : 'false';
disableDownload = 'disabledownload' in params ? params.disabledownload : 'false';
disableBookmark = 'disablebookmark' in params ? params.disablebookmark : 'false';
validateFileURL(file);
const fileInput = document.createElement("input");
fileInput.id = appConfig.openFileInputName;
@ -2329,8 +2337,30 @@ function webViewerInitialized() {
PDFViewerApplication._documentError(msg, reason);
});
}
if ('true' === disablePresentationMode) {
document.getElementById("presentationMode").style.display='none';
document.getElementById("secondaryPresentationMode").style.display='none';
}
if ('true' === disableOpenFile) {
document.getElementById("openFile").style.display='none';
document.getElementById("secondaryOpenFile").style.display='none';
}
if ('true' === disablePrint) {
document.getElementById("print").style.display='none';
document.getElementById("secondaryPrint").style.display='none';
}
if ('true' === disableDownload) {
document.getElementById("download").style.display='none';
document.getElementById("secondaryDownload").style.display='none';
}
if ('true' === disableBookmark) {
document.getElementById("viewBookmark").style.display='none';
document.getElementById("secondaryViewBookmark").style.display='none';
}
}

View File

@ -26,7 +26,7 @@
if (!url.startsWith(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(url);
}
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disabledownload=${pdfDownloadDisable}";
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disablepresentationmode=${pdfPresentationModeDisable}&disableopenfile=${pdfOpenFileDisable}&disableprint=${pdfPrintDisable}&disabledownload=${pdfDownloadDisable}&disablebookmark=${pdfBookmarkDisable}";
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
/**
* 页面变化调整高度