From ee2a27501b8e46c52b56595f08d62445e688697c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Wed, 15 Apr 2026 14:40:41 +0800 Subject: [PATCH 1/5] =?UTF-8?q?pdf=20=E6=B7=BB=E5=8A=A0=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20=E4=BF=AE=E5=A4=8Dpdf=20=E9=A1=B5=E7=A0=81?= =?UTF-8?q?=E5=92=8C=E9=AB=98=E4=BA=AE=E6=B2=A1=E5=90=AF=E7=94=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/pdfjs/web/viewer.mjs | 38 +++++---- server/src/main/resources/web/pdf.ftl | 85 +++++++++++++------ 2 files changed, 79 insertions(+), 44 deletions(-) diff --git a/server/src/main/resources/static/pdfjs/web/viewer.mjs b/server/src/main/resources/static/pdfjs/web/viewer.mjs index 7d29b129f..78f47697e 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.mjs +++ b/server/src/main/resources/static/pdfjs/web/viewer.mjs @@ -23083,24 +23083,26 @@ initCom(PDFViewerApplication); } { const HOSTED_VIEWER_ORIGINS = new Set(["null", "http://mozilla.github.io", "https://mozilla.github.io"]); - var validateFileURL = function (file) { - if (!file) { - return; - } - const viewerOrigin = URL.parse(window.location)?.origin || "null"; - if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) { - return; - } - const fileOrigin = URL.parse(file, window.location)?.origin; - if (fileOrigin === viewerOrigin) { - return; - } - const ex = new Error("file origin does not match viewer's"); - PDFViewerApplication._documentError("pdfjs-loading-error", { - message: ex.message - }); - throw ex; - }; +var validateFileURL = function (file) { + if (!file) { + return; + } + const viewerOrigin = URL.parse(window.location)?.origin || "null"; + if (HOSTED_VIEWER_ORIGINS.has(viewerOrigin)) { + return; + } + /* 注释掉跨域检查 + const fileOrigin = URL.parse(file, window.location)?.origin; + if (fileOrigin === viewerOrigin) { + return; + } + const ex = new Error("file origin does not match viewer's"); + PDFViewerApplication._documentError("pdfjs-loading-error", { + message: ex.message + }); + throw ex; + */ +}; var onFileInputChange = function (evt) { if (this.pdfViewer?.isInPresentationMode) { return; diff --git a/server/src/main/resources/web/pdf.ftl b/server/src/main/resources/web/pdf.ftl index fb2e44c50..068ef8f1d 100644 --- a/server/src/main/resources/web/pdf.ftl +++ b/server/src/main/resources/web/pdf.ftl @@ -1,55 +1,88 @@ - + PDF预览 <#include "*/commonHeader.ftl"> + - + <#if pdfUrl?contains("http://") || pdfUrl?contains("https://")> <#assign finalUrl="${pdfUrl}"> <#else> <#assign finalUrl="${baseUrl}${pdfUrl}"> - + + + <#if "false" == switchDisabled> - 使用图片预览 + 使用图片预览 - - + + \ No newline at end of file From c52d80c1230d7ff3cb1d462b707f25245c8a9d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Thu, 16 Apr 2026 11:21:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E5=92=8C=E9=AB=98=E4=BA=AE=20=E7=89=B9=E6=AE=8A=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E4=BC=9A=E5=AF=BC=E8=87=B4=E8=A7=A3=E6=9E=90=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/main/resources/web/pdf.ftl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/main/resources/web/pdf.ftl b/server/src/main/resources/web/pdf.ftl index 068ef8f1d..39ca6e4c5 100644 --- a/server/src/main/resources/web/pdf.ftl +++ b/server/src/main/resources/web/pdf.ftl @@ -53,15 +53,17 @@ url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url)) + "&key=${kkkey}"; } var viewerUrl = baseUrl + "pdfjs/web/viewer.html?file=" + encodeURIComponent(url); + var watermarkEncoded = encodeURIComponent('${watermarkTxt?js_string}'); + var highlightEncoded = encodeURIComponent('${highlightall?js_string}'); viewerUrl += "&disablepresentationmode=${pdfPresentationModeDisable}"; viewerUrl += "&disableopenfile=${pdfOpenFileDisable}"; viewerUrl += "&disableprint=${pdfPrintDisable}"; viewerUrl += "&disabledownload=${pdfDownloadDisable}"; viewerUrl += "&disablebookmark=${pdfBookmarkDisable}"; viewerUrl += "&disableediting=${pdfDisableEditing}"; - viewerUrl += "&pdfhighlightall=${highlightall}"; - viewerUrl += "&watermarktxt=${watermarkTxt}"; - viewerUrl += "#page=${page?js_string}"; + viewerUrl += "&watermarktxt=" + watermarkEncoded; + viewerUrl += "&pdfhighlightall=" + highlightEncoded; + viewerUrl += "#page=${page}"; // ?c 确保数字不包含千位分隔符 viewerUrl += "&pagemode=thumbs"; var iframe = document.getElementById('pdfFrame'); iframe.src = viewerUrl; From 633e47b765444dcf4fc23eae8f067d73a5c22e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Thu, 16 Apr 2026 17:26:41 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E5=90=8E=20=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/main/resources/static/pdfjs/web/viewer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/resources/static/pdfjs/web/viewer.html b/server/src/main/resources/static/pdfjs/web/viewer.html index 629bb8585..a13eab986 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.html +++ b/server/src/main/resources/static/pdfjs/web/viewer.html @@ -1221,8 +1221,8 @@ - - + +
From dd803126ddb6faf491e498f264a77ee5c66e0d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Thu, 16 Apr 2026 17:32:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E5=90=8E=20=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/main/resources/static/pdfjs/web/viewer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/resources/static/pdfjs/web/viewer.html b/server/src/main/resources/static/pdfjs/web/viewer.html index a13eab986..42d32db76 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.html +++ b/server/src/main/resources/static/pdfjs/web/viewer.html @@ -1221,8 +1221,8 @@ - - + +
From cd2abb4be1cb3d5f1d53326b60c1c1f58fd1ac4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=9B=84?= Date: Fri, 17 Apr 2026 17:37:03 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E5=90=8E=20=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/main/resources/static/pdfjs/web/viewer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/resources/static/pdfjs/web/viewer.html b/server/src/main/resources/static/pdfjs/web/viewer.html index 42d32db76..48548ca8e 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.html +++ b/server/src/main/resources/static/pdfjs/web/viewer.html @@ -1221,8 +1221,8 @@ - - + +