How to set favicon.ico on a pdf link? - java

I am working on web project in java where i have to open a pdf file by the link :
View User Manual
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...

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

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.

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.

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.

Related

Mounting a PDF via wicket

I am new to wicket and need to load a PDF, using Java and Wicket, when a user enters a URL. For example, typing in the URL:
www.domain.com/pdf/myDocument
will force the document www.domain.com/pdf/myDocument.pdf to be loaded
The reason for doing this is that I have a bunch of PDF documents in the webapp folder of my Java project. A printed letter that is being mailed to customers has a link to one of these documents but is missing the PDF file extension. I therefore need to put something in place that intercepts this URL and load the appropriate PDF resource.
Many thanks for any help.
Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/. You can load with webApplication.getServletContext().getResource(parameters.get(0).toString() + ".pdf")

Display PDF in browser

I am developing a Java Web Application (jsp/servlet) using tomcat. I need to display pdf file from local machine. can you suggest what is best way to display it?
I used iframe to display pdf file.
<iframe src="resume.pdf" width="100%" style="height:60em">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access the document
via a link though.]
</iframe>
I think you can try a Library called XPDF , I think you can convert from PDF to HTML page , or the second option is just let the user open a link to the page (www.yourwebsite.com/pdffolder/somepdf.pdf)
If you need display a pdf file using tomcat, you can access directly to the file using the specific url where the file is located in your navigator, depending on the path where you put the file, so you can access using 127.0.0.1/files/test.pdf for example. If you need generate a pdf, the best tool I think is iText, this is an easy example how to use id: Introducing PDF and iText

save webpages for offline browsing

i am trying to create an android application that saves webpages to use it in offline-browsing, i was able to save the webpage but the problem was in the contents (images, javascripts,..etc), is there a way to do so programmatically, i use eclipse and test my work on an emulator.
hm, I am afraid you should parse html's yourself (I mean do that with a properly lib) and store all resources (css, js, images, videos etc.) too.
s. how it is done in a java crawler: open source crawlers
You will need to search for all images, javascript files, css files, etc... and download them, saving them to the same relative path to the HMTL files - Assuming the html is coded with relative paths (images/image.png) and not absolute paths (http://www.domain.com/image/image.png).
You can pretty easily search the html string for <img, <script, <link etc.. and parse from there - or you can find a 3rd party html parser

How To download web page using java as well preserve image files

How to download the page and the images given the url using java. A similar question was avaialble already, which when tried just saves the page and not the images.
You'll have to download the page (HTML), then parse the HTML, find the <img> tags in there, and download the images (the src attribute of the <img> tag is the URL of the image file). Likewise you might want to download accompanying CSS or JavaScript files for the page.
Java makes it easy to copy files from a Web site

What is the best way of opening PDFs from a JSP?

I would like some guidance on the best way of launching PDFs from a browser.
I have a JSP that takes some parameters and based on this downloads a PDF from my Documentum server. The files are stored on my local file system. I then provide the user with a bunch of links to the PDFs so they can click on them to launch the PDF.
Is there a best practice method of doing this?
Thanks.
There is nothing special to do: a link is sufficient. But you can add target="_new" if you want the browser to open the pdf in a new window.
Just make sure that the content-type returned for the pdf is application/pdf.

Categories

Resources