From 3e4a159a45196a244d05aaa2c8505c278a3b8bb4 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 17 Jun 2018 13:44:35 +0200 Subject: [PATCH] Set the correct document title when opening a new file in the `GENERIC` default viewer --- web/app.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index f183880db..9242cf995 100644 --- a/web/app.js +++ b/web/app.js @@ -615,7 +615,7 @@ let PDFViewerApplication = { }); }, - setTitleUsingUrl(url) { + setTitleUsingUrl(url = '') { this.url = url; this.baseUrl = url.split('#')[0]; let title = getPDFFileNameFromURL(url, ''); @@ -1928,8 +1928,13 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { let file = evt.fileInput.files[0]; if (URL.createObjectURL && !AppOptions.get('disableCreateObjectURL')) { - PDFViewerApplication.open(URL.createObjectURL(file)); + let url = URL.createObjectURL(file); + if (file.name) { + url = { url, originalUrl: file.name, }; + } + PDFViewerApplication.open(url); } else { + PDFViewerApplication.setTitleUsingUrl(file.name); // Read the local file into a Uint8Array. let fileReader = new FileReader(); fileReader.onload = function webViewerChangeFileReaderOnload(evt) { @@ -1939,8 +1944,6 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { fileReader.readAsArrayBuffer(file); } - PDFViewerApplication.setTitleUsingUrl(file.name); - // URL does not reflect proper document location - hiding some icons. let appConfig = PDFViewerApplication.appConfig; appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');