From c00e237421f7e77a7e4841edd92c0c8a942c5c11 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 6 Feb 2023 11:56:15 +0100 Subject: [PATCH] Remove inline opening of PDF attachments in the COMPONENTS build The `DownloadManager.openOrDownloadData` method is written for the default-viewer specifically, assuming a viewer able to handle e.g. URL search/hash parameters. In the viewer components there's obviously no such functionality, and we should thus trigger downloading of PDF attachments directly instead. --- web/download_manager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/download_manager.js b/web/download_manager.js index e7d031c63..cb1cc6d4c 100644 --- a/web/download_manager.js +++ b/web/download_manager.js @@ -71,7 +71,10 @@ class DownloadManager { const isPdfData = isPdfFile(filename); const contentType = isPdfData ? "application/pdf" : ""; - if (isPdfData) { + if ( + (typeof PDFJSDev === "undefined" || !PDFJSDev.test("COMPONENTS")) && + isPdfData + ) { let blobUrl = this.#openBlobUrls.get(element); if (!blobUrl) { blobUrl = URL.createObjectURL(new Blob([data], { type: contentType }));