How to set favicon.ico on a pdf link?

10,655

Solution 1

In Chrome, do the following:

  1. Place the favicon in the root of your website, and call it favicon.ico

  2. Clear the cache

  3. Load the PDF from your website

Solution 2

You can't. A favicon is something that can be set on a HTML page, but not on a PDF file. You might be able to do that by linking to a HTML page which has a favicon and contains an iframe containing the PDF file, but it seems overkill for just a favicon.

Solution 3

You can try the default favicon location - i.e. place favicon.ico on the root of server (which is normally the ROOT application). In production you will almost always be running as ROOT. But I don't know if browsers will recognize that - if they don't, it means you can't do it. PDFs are read in the browser only if there's a plugin, so perhaps the normal favicon resolution doesn't happen.

Solution 4

You could try using a php script to deliver the pdf and setting a favicon in the header there. But I don't think thats worth the effort.

Share:
10,655
Asif
Author by

Asif

Updated on June 15, 2022

Comments

  • Asif
    Asif almost 2 years

    I am working on web project in java where i have to open a pdf file by the link :

    <a href="files/help.pdf" target="_blank" title="User Manual (pdf)">View User Manual</a>

    I know how to set favicon on the links but didn't know how to set it on this pdf file..

    Can anyone have the answer?

    Thanks in advance...

  • Asif
    Asif over 12 years
    didn't get what is actual mean of root?? Sorry...m newbee to java web..and currently working with Apache Tomcat and NetBeans
  • Asif
    Asif over 12 years
    Actually the bad thing is, it displays the Apache symbol at place of favicon, and if mine could not be there how can Apache's?
  • Bozho
    Bozho over 12 years
    in your web application's root. Normally, tomcat/webapps/yourapp/. Or the folder where WEB-INF is placed.
  • Bozho
    Bozho over 12 years
    well, then it is not supported. You can't do it
  • Asif
    Asif over 12 years
    But i dont like the Apache's icon on the same pdf... Is it way to remove that one ? hahaha
  • JB Nizet
    JB Nizet over 12 years
    Probably because the root webapp (i.e. the webapp deployed on the root context, under /) has a default favicon. Just remove the ROOT directory from the webapps folder of your tomcat install, and you shouldn't see it anymore. Or just remove the favicon.ico from this ROOT folder. Or, as Bozho suggested, replace it with yours.
  • JB Nizet
    JB Nizet over 12 years
    @Bozho: for the browser, the root of the webapp doesn't constitute a root. It's just a subfolder of the root of the server. The OP should replace the ROOT's favicon with his own favicon. ROOT is the webapp deployed on the root, under /.
  • Bozho
    Bozho over 12 years
    @JB Nizet, yup, true. I assumed he is running the root app, but obviously incorrectly. I'll fix my answer
  • Asif
    Asif over 12 years
    I removed the favicon, i replaced it by mine, i removed the ROOT directory, i restarted the server every time, i reload my app everytime, but, nothing happens...it seems i should be happy with what i get with the hyperlinks and not to try it on pdf's... :)
  • Bozho
    Bozho over 12 years
    Sure you can set that with a header? (besides, he's using java, not php)
  • NCode
    NCode over 12 years
    Not sure at all, but it would be worth googling it
  • MFarooqi
    MFarooqi about 8 years
    i did the same, and found your later. this really works.