mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Set title using logic similar as download name
The download method (and the PDF document properties) detect the file name using `getPDFFileNameFromURL`. The title ought to also display the PDF filename if available.
This commit is contained in:
parent
228d253f30
commit
c67edabcb3
2 changed files with 16 additions and 9 deletions
17
web/app.js
17
web/app.js
|
@ -569,14 +569,17 @@ var PDFViewerApplication = {
|
|||
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
||||
this.url = url;
|
||||
this.baseUrl = url.split('#')[0];
|
||||
try {
|
||||
this.setTitle(decodeURIComponent(
|
||||
pdfjsLib.getFilenameFromUrl(url)) || url);
|
||||
} catch (e) {
|
||||
// decodeURIComponent may throw URIError,
|
||||
// fall back to using the unprocessed url in that case
|
||||
this.setTitle(url);
|
||||
var title = getPDFFileNameFromURL(url, '');
|
||||
if (!title) {
|
||||
try {
|
||||
title = decodeURIComponent(pdfjsLib.getFilenameFromUrl(url)) || url;
|
||||
} catch (e) {
|
||||
// decodeURIComponent may throw URIError,
|
||||
// fall back to using the unprocessed url in that case
|
||||
title = url;
|
||||
}
|
||||
}
|
||||
this.setTitle(title);
|
||||
},
|
||||
|
||||
setTitle: function pdfViewSetTitle(title) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue