How to set favicon.ico on a pdf link?
Solution 1
In Chrome, do the following:
Place the favicon in the root of your website, and call it favicon.ico
Clear the cache
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.
Asif
Updated on June 15, 2022Comments
-
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 over 12 yearsdidn't get what is actual mean of root?? Sorry...m newbee to java web..and currently working with Apache Tomcat and NetBeans
-
Asif over 12 yearsActually 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 over 12 yearsin your web application's root. Normally, tomcat/webapps/yourapp/. Or the folder where WEB-INF is placed.
-
Bozho over 12 yearswell, then it is not supported. You can't do it
-
Asif over 12 yearsBut i dont like the Apache's icon on the same pdf... Is it way to remove that one ? hahaha
-
JB Nizet over 12 yearsProbably 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 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 over 12 years@JB Nizet, yup, true. I assumed he is running the root app, but obviously incorrectly. I'll fix my answer
-
Asif over 12 yearsI 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 over 12 yearsSure you can set that with a header? (besides, he's using java, not php)
-
NCode over 12 yearsNot sure at all, but it would be worth googling it
-
MFarooqi about 8 yearsi did the same, and found your later. this really works.