Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Firefox tab's title while viewing PDFs is constituted from first PDF's title metadata then file's name, how change it

more options

See a code here: https://github.com/mozilla/pdf.js/pull/1500/commits

I want , not document.title = pdfTitle + ' - ' + document.title; but document.title = document.title + ' - ' + pdfTitle

Since,

  1. The titles of PDFs which I often deal with in my work are usually irrelevant than the content (for example the URL of PDF generators' webpage)
  2. changing title to a relevant one is harder than changing just the filename
  3. the visible portion of title visible on Firefox tabs is barely enough to display only the title of PDFs

I want to change it. Any help would be appreciated. Any pdfjs setting, viewer.js or any other solution. But no programming skills, so step by step guide will be useful, if any.

See a code here: https://github.com/mozilla/pdf.js/pull/1500/commits I want , not document.title = pdfTitle + ' - ' + document.title; but document.title = document.title + ' - ' + pdfTitle Since, # The titles of PDFs which I often deal with in my work are usually irrelevant than the content (for example the URL of PDF generators' webpage) # changing title to a relevant one is harder than changing just the filename # the visible portion of title visible on Firefox tabs is barely enough to display only the title of PDFs I want to change it. Any help would be appreciated. Any pdfjs setting, viewer.js or any other solution. But no programming skills, so step by step guide will be useful, if any.

Endret av ahmetgns

All Replies (5)

more options

To change the tab title in Firefox when viewing PDFs, you can try the following steps:

1)Open Firefox and go to the "about:config" page. 2)In the search bar, type "pdfjs.removePageBars" and press Enter. 3)Double-click on the "pdfjs.removePageBars" preference to set its value to "true". 4)Close and reopen Firefox.

This should change the tab title to only show the PDF's file name when viewing PDFs in Firefox. If you want to revert the change, you can follow the same steps and set the value of "pdfjs.removePageBars" back to "false".

more options

Hi Mich, I can't find that preference in Firefox 108. Are you running a different version?

Hi ahmetgns, I agree that having all your tabs say Microsoft Word because the PDF has that in its title is not very useful. On the other hand, it's difficult to know when the title in the metadata might be more useful than the file name assigned by a site when you download a file (if you aren't naming it yourself).

By the way, the current pdf.js title code is here:

https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1458

I don't know what the prospects are for getting that changed.

For the time being, you might need to take matters into your own hands and change the title yourself using a snippet of JavaScript (for example, saved as a bookmarklet). For example:

var parts = document.title.split(' - ');
parts.unshift(parts.pop());
document.title = parts.join(' - ');


You may wonder... what? This code creates an array of pieces of the page title based on using " - " as a delimiter. It then pops off the last item in the array and inserts it as the first item. It then updates the title with the new order.

If you want to try it, you can open the Web Console in the PDF viewer (Ctrl+Shift+K), then paste and "run" the code (in the multi-line editor there is a Run button, in the single-line editor, you just press Enter). The first time you use the console, Firefox will ask you to take an action to confirm you understand it is dangerous to run code from strangers. That's definitely true!

Endret av jscher2000 - Support Volunteer

more options

Thank you Mich & jscher2000.

I couldn't find pdfjs.removePageBars option but I created it as a Boolean option and its value was set to true when created. However, after restart of Firefox it didn't help. The tab was still constituted from the PDF's title metadata and then its filename.

jscher2000's code runned successfully. Two negative aspects: I have to open console for each tab after opening files and run the code seperately, but I wanted a default setting. The second negative one; since the delimiter in the code is "-", if the filename or PDF's metadata title include it already, on each run, the parts shifts in order.

Thanks for the current pdfjs\app.js code's URL jscher2000's . Anyone who can help to modify the code and run it on my computer.

more options

You can fork the repository, change the code and build&install extension.

more options

ahmetgns said

jscher2000's code runned successfully. Two negative aspects: I have to open console for each tab after opening files and run the code seperately, but I wanted a default setting. The second negative one; since the delimiter in the code is "-", if the filename or PDF's metadata title include it already, on each run, the parts shifts in order.

You can simplify execution by saving the script as a bookmarklet (a bookmark whose URL starts with javascript: instead of https://). The code is:

javascript:var parts=document.title.split(' - ');parts.unshift(parts.pop());document.title=parts.join(' - ');void 0;

and/or you can install it from here:

https://www.jeffersonscher.com/res/sumomarklets.html#PDFTitle

On the second point, it should not be very common that a file name has a hyphen with a space on each side, but if that affects the files you're opening, I don't have a workaround.

For fun, I asked ChatGPT to explain the scripts. See attached screen captures. Not too bad!