Display favicon for PDF files

六眼飞鱼酱① 提交于 2019-11-29 13:46:52
Pekka 웃

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

s1m0n1stv4n

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
RichardLynch

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.

BillVo

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

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