Display favicon for PDF files

你。 提交于 2019-11-28 07:19:04

问题


I am working on a Drupal site with some PDF files where I am opening a PDF file in a new window. The files are getting opened in the browser with the Acrobat Reader plugin but the favicon is not getting displayed. What should be done to show the favicon?


回答1:


If you show the PDF file in an iframe, the browser should show the site-wide favicon, but you're out of luck in an external applications. Acrobat Reader doesn't use Favicons.

UPDATE This is now possible by placing favicon.ico in the root directory of your website as per @s1m0n1stv4n answer below




回答2:


If you put a favicon.ico to the root of your site, then your PDFs opened on that site will actually have that favicon. You can generate transparent ICOs from PNGs with online favicon genereators.

For example, if your favicon is reachable in:

http://example.com/favicon.ico

Then your PDF will show this favicon in the Acrobat plugin tab:

http://example.com/something/something.pdf



回答3:


In the Drupal root directory, edit the .htaccess file and add this:

RewriteRule ^favicon.ico sites/%{SERVER_NAME}/favicon.ico [NC,L]

Exactly as it is typed there, and right after the RewriteBase line near the bottom.

See caveats here: http://drupal.org/node/174940#comment-852888

This assumes you have friendly URLs working in Drupal, or the RewriteRule will be useless.

In each sites/example.com/ directory, add the favicon.ico for that site.

Jump through hoops to clear your favicon cache in your browser / OS: http://www.faviconblog.com/clear-the-browser-cache-to-display-your-favicon/

This MAY over-ride the HTML HEAD favicon that Drupal spits out when you upload one in some browsers, or not. Haven't tested. If it does, you'll have to have a favicon.ico for every sites/XYZ/

Note that just because uploaded HEAD favicon overrides the sites/XYZ/ in one browser, is no indication it will work in another, or vice versa.




回答4:


Displaying the PDF from <iframe>, <object>, or maybe even <embed> tag inside of an HTML page should result in the favicon being used.



来源:https://stackoverflow.com/questions/4886423/display-favicon-for-pdf-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!