It's not a secret anymore!*
The moose likes Applets and the fly likes Can a web application open a pdf file that exists on the client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Can a web application open a pdf file that exists on the client side" Watch "Can a web application open a pdf file that exists on the client side" New topic
Author

Can a web application open a pdf file that exists on the client side

Martha Liakopoulou
Greenhorn

Joined: Jul 26, 2012
Posts: 1
Hi,

I'm not a java developer, but I found an aswer in this forum similar to what I am trying to do in ASP and PHP. The link is http://www.coderanch.com/t/328414/java/java/open-local-file-Java-program .

Here is what I want to do: I have an ASP site (and an equivalent in PHP) and based on an id that the user enters in an ASP page, I calculate a path, e.g c:\myFolfer\file1.pdf. This path refers to the client's computer, and I need to open a popup and show the user the pdf that he already has stored on his pc. These pdf files are not stored at the server and I cannot change the application so that they are uploaded to the server. I just need to show a file that is stored at the client.

I read the post mentioned before, where it says "So it's a Web application, and the PDF file is already on the desktop machine. This is not the kind of scenario that Web technologies are built to deal with, unfortunately. The only way that occurs to me to do this is to have a signed Java applet on the web page; that signed applet can ask for and be granted (by the user) permission to launch an application with that file. It's a lot of work, it's messy, and users won't like granting the permission."

So, my question is: Is a signed applet the only way to do this? If so, could you give me some directions where to start? Or could I find something free in the web?

Many thanks
Martha
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

Yes, a signed Java applet has permission to read local resources on user's computer, including PDF files.
There are some free (LGPL) versions of PDF reader programs on the web such as JPedal which you can use in your applet.


PM Me If You Want to get Urgent Help on Java Programming
Kathleen Angeles
Ranch Hand

Joined: Aug 06, 2012
Posts: 122

How about generating an html link (e.g. and anchor html tag) pointing to the file in the harddisk, and inform the user to click it? It may trigger the default client pc's pdf reader to open it.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

What happens if you generate a block of code like the one below, replacing the path to the pdf with the location on the local pc?



Note: replace the {} with <>. i did this because my code doesn't appear correctly in this post.


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can a web application open a pdf file that exists on the client side