aspose file tools*
The moose likes JSF and the fly likes jsf: open pdf in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf: open pdf in browser" Watch "jsf: open pdf in browser" New topic
Author

jsf: open pdf in browser

lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
I have post a similar post in "other open source projects forum", but not getting any reponse, thus trying here to get some response.

i having in opening the pdf, i want to have dialog bos to pop up asking user to save or open the file:

full details in :
http://www.coderanch.com/t/446738/Other-Open-Source-Projects/jsf-jasper-report-pdf-format

with the piece of code:
IE: nothing happens when i click on the command button, the method is call without any error
FF: new window open up, with binary data

I tried also using:
response.setHeader("Content-disposition", "inline; filename=\""+filename +".pdf\"");
both IE and FF nothing happens when i click on the command button, the method is call without any error.


anyone?

Thanks.


Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

So, I can anticipate a number of problems with this design flaw, not the least of which is pop-up blockers. I know when Chrome downloads something, it just puts an icon in the lower left-hand corner, which can easily be missed.

Why not have a link on the page that just allows the user to right-click on the link and select Save-As, as they would in any browser. Or, just allow the PDF to open, and have the user use the native Save option provided by Adobe/Foxit.

I know it's not solving the problem. But simply doing a redesign might actually eliminate the problem altogether. Plus, nobody likes pop-ups.

-Cameron McKenzie
lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
Well of cause, i know popup is not a good idea. but i dont really mean as "pop up window". I set the
response.setHeader("Content-disposition", "attachment; filename=\""+filename +".pdf\""); this will instruct the browser to attached the file to the reponse, so that user can download the file.


Why not have a link on the page that just allows the user to right-click on the link and select Save-As, as they would in any browser

I do not want to store the file on my server. I just want to generate the file on-the-fly for the user



Or, just allow the PDF to open, and have the user use the native Save option provided by Adobe/Foxit.


I have thought about this. but my problem is now i cannot even get the PDF to open.. using
response.setHeader("Content-disposition", "inline; filename=\""+filename +".pdf\"");

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Good points.

I might try a quick test and see if you can get it to work in both browsers with an Excel document, or some other type of application or data file. It might be worth seeing if it is a pdf specific issue, or an issue that's just coming up with that particular MIME type mapping?

Just an idea.

-Cameron McKenzie
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16233
    
  21

I hope you haven't started parallel discussions here. There's a reason why we really prefer to have people only run a topic in one place.

Internet Explorer is prohibited from opening PDF's embedded within a browser window. The "technology" required to do so is patented by a small company who sued Microsoft for a half a billion dollars and won. So Microsoft was obliged to remove that feature. Regardless of what you set your headers to, IE users will always get a separate stand-alone application launch for PDF's, Excel spreadsheets and other documents that were formerly embeddable. Just to make it more confusing, it's the up-to-date Windows systems where you'll see this. There were still some older ones that could embed last time I looked. But that was a while back.

Embedding is supposed to be legal in FireFox and on non-Windows machines, by permission of the patent holder (whose name I have forgotten at the moment). However, they, too sometimes are set up not to embed.

Finally, I believe that the embed/non-embed option was a user-settable option in at least some systems.

If you get nothing back at all, you've got a webapp bug. But embedability is system-specific.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gary Leung
Greenhorn

Joined: Jul 28, 2009
Posts: 1
I try to focus to your question first. I 've done a project which is similar to your suitation. But i used to following fragment code instead of yours,




After you clicked the link of the servlet which contained the above codes, there was a window prompted out and asked you whether you save or open the file and did not leave a file in a server. Hope it helps
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: jsf: open pdf in browser