• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pdf in web browser

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have saved pdf in a file now i want to show that pdf in web browser .then how it is possible to that?
thanks in advance
 
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
some pdf viewer software give plugin for browser to display pdf on any browser....try foxit pdf viewer or adobe
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thakur Sachin Singh wrote:some pdf viewer software give plugin for browser to display pdf on any browser....try foxit pdf viewer or adobe




we cannot do it with the help of programming....
 
Thakur Sachin Singh
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you can do this but we can not write direct code for this, here you need to use third party api's, search on google for this.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://viralpatel.net/blogs/2009/04/generate-pdf-file-in-java-using-itext-jar.html

check with this.
 
Ranch Hand
Posts: 171
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if your question is something like you have a pdf on server & you want to display it on client machine's browser, then you have to do the following -

set response header Content-Disposition as inline
set response header Content-Type as application/pdf

After this, write your pdf file into the response.

you can use it directly or can use an iframe to display it within your web page. Hope that answers
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the client does not have software installed for viewing PDFs, then there's nothing the web app can do about that.

iText does not help with viewing PDFs; it is used to create and alter PDFs.
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anurag Verma wrote:if your question is something like you have a pdf on server & you want to display it on client machine's browser, then you have to do the following -

set response header Content-Disposition as inline
set response header Content-Type as application/pdf

After this, write your pdf file into the response.

you can use it directly or can use an iframe to display it within your web page. Hope that answers


I have used this also but problem is not solved....
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what, exactly, is the code doing now, what, exactly, is the result of that, and how, exactly, does that differ from what you expected to happen?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is more legal than technical.

Internet Explorer is forbidden from displaying PDF's in a browser window. It is likewise forbidden from allowing the viewing or editing of MS-Word or Excel documents or any similar applications.

Several years ago, a small company named Eolas sued Microsoft, claiming that they had a patent on that process. They won, and Microsoft was assessed a penalty of one half billion dollars. That's correct. As in "50 crore" dollars. Microsoft had no success in the appeal (although reportedly, they did get a reduction in how much to pay), so they pulled the functionality out of IE.

Eolas apparently had it in for Microsoft, since they announced that other vendors were allowed to continue to embed documents in their browers. I can and do view PDF's in Firefox.

More recently, Eolas reappeared in a lawsuit relating to their patents allegedly covering video streaming and other browser-interactive content. They lost that one, but not before collecting from a lot of big-name players.
 
Anurag Verma
Ranch Hand
Posts: 171
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be precise on what you want , what is happening, provide exceptions/logs (& code if possible). In short, ask the correct & precisely detailed question.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although a bare "It doesn't work" is something we discourage around here (we're weak in the ESP department), this is a common enough case that I'm pretty sure that it meant "It launched the Adobe Reader instead of opening in a browser" based on the original question.

Of course, I could be wrong. In which case we do need to know what actually happened.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Tim - thanks for giving us nice information ....

~ abhay
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rakhi sinha wrote:

Anurag Verma wrote:if your question is something like you have a pdf on server & you want to display it on client machine's browser, then you have to do the following -

set response header Content-Disposition as inline
set response header Content-Type as application/pdf

After this, write your pdf file into the response.

you can use it directly or can use an iframe to display it within your web page. Hope that answers


I have used this also but problem is not solved....



I am using following code but no pdf is displayed in the browser.a zero size pdf is generated because i think it is not taking signed pdf which is stored in resources folder but it is createing new signed pdf of zero size.I want that saved signed pdf( in resources folder) in my web browser..


how can i solve my problem..
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.

I've gone ahead and added the code tags for you. See how much easier the code is to read?


thanks .i will take care of this in future.....
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should NEVER attempt to write to your WAR. It isn't supported by the J2EE spec,it isn't guaranteed to work (getRealPath may return NULL), and you can lose important data when a new version of the WAR is deployed.

It is OK to READ signatures and model PDF files from within a WAR, but not to write or update. Officially, a WAR is a ZIP (JAR) format file, and you cannot open a member of a ZIP file for reading or writing the way you can do for an independent file. You cannot even reliably read the resource using getRealPath() for that reason, which is why there's a "getResourceAsStream()" method that handles that situation.

Always write to a location that's external both to the webapp (WAR) and to the webapp server.
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:You should NEVER attempt to write to your WAR. It isn't supported by the J2EE spec,it isn't guaranteed to work (getRealPath may return NULL), and you can lose important data when a new version of the WAR is deployed.

It is OK to READ signatures and model PDF files from within a WAR, but not to write or update. Officially, a WAR is a ZIP (JAR) format file, and you cannot open a member of a ZIP file for reading or writing the way you can do for an independent file. You cannot even reliably read the resource using getRealPath() for that reason, which is why there's a "getResourceAsStream()" method that handles that situation.

Always write to a location that's external both to the webapp (WAR) and to the webapp server.



thanks for your suggestion ......i have done it
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic