When I print a webpage to PDF in Firefox, it saves the file but without the .pdf extension in the name. I have installed various add-ons but ended up with the same result.
I don't want to manually rename my files with the file manager.

Is there a setting somewhere to change this behaviour so that the file name is always suffixed with `.pdf'?

And how can I set it up to open the file with the default PDF viewer automatically after it got created?

  • 2
    Are you printing from within Firefox? If so, what is the problem? When you choose "Print to file" it suggests mozilla.pdf as the name and you can change the prefix to whatever you want. The result, for me at least, is a pdf file with the pdf extension. – DK Bose Nov 17 '15 at 13:38

You can just simply add the .pdf suffix to the file name you chose yourself.

On Linux systems, files are not judged by their extensions, but by their content or actually by the first few bytes of their content. That way it can determine with what applications to open a file without having to rely on the names. This might sound confusing for Windows users but works pretty well.

So as long as you only need that PDF document on your Ubuntu system, there's no need for an extension unless you want it. And if you want to open it on Windows, you could manually rename the file (e.g. with your Files manager nautilus) afterwards.

Or as I already said, just directly enter the full name including the .pdf extension into the print dialogue. It will even remember the name you used last (or default to mozilla.pdf, this probably depends on the version), so that you can just leave the extension there and overwrite the basename only.

enter image description here

| improve this answer | |
  • This is a tedious fix. Also, when I use the print to pdf function in Firefox I make sure that the pdf option is set. I'm telling it to print the file as pdf and it doesn't do it? – David Ashton Nov 17 '15 at 13:32
  • 1
    It is not. Those are 4 characters and you have to edit this field's content anyway. Besides, Firefox keeps the last filename stored and presents it to you as default value. So you only have to enter them once and then just overwrite the rest. – Byte Commander Nov 17 '15 at 13:34

Firefox comes with its own PDF printer, which works well, but a alternative is to use the CUPS PDF printer (I think part of the cups-pdf package). This will should work with all apps that can print by adding a extra printer which outputs a PDF file (by default on the desktop I think) - it also automatically adds a appropriate filename based on the title (e.g. Automatically_add___pdf__extension_and_open_resulting_file_when_.pdf)

enter image description here

For opening the file automatically, it may be possible by defining your printer which (using a script) converts the page a pdf (using GhostScript or another program), saves it and then opens the default PDF viewer. It should be possible to find out how add a printer by examing the files installed by the Cups PDF printer package, or perhaps by using Cups commands to a custom PPD file (see here)

| improve this answer | |

The command in step 4 monitors your download folder by using a script (see step 2). The script checks the mimetype newly added files. If the file is a PDF, then a suffix is added, if necessary, and the file is opened.

  1. Install the package inoticoming

    sudo apt-get install inoticoming
  2. Create wrapper script handlePdfDownload

    mkdir -p ~/bin
    nano ~/bin/handlePdfDownload
  3. Add the code below

    #!/usr/bin/env bash
    if [ "$(mimetype -b "$FOLDER/$FILE")" != "application/pdf" ]; then
        exit 1
    if [ "${FILE##*.}" != "pdf" ]; then
        mv "$FOLDER/$FILE" "$FOLDER/$FILE.pdf"
    xdg-open "$FOLDER/$FILE.pdf"
    exit 0
  4. Set the executable bit

    chmod +x ~/bin/handlePdfDownload
  5. Watch your Downloads folder

    inoticoming ~/Downloads ~/bin/handlePdfDownload {} ~/Downloads \;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.