Set the correct document title when opening a new file in the GENERIC default viewer

This commit is contained in:
Jonas Jenwald 2018-06-17 13:44:35 +02:00
parent 84920f39b2
commit 3e4a159a45

View File

@ -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');