aspose file tools*
The moose likes Other Open Source Projects and the fly likes Open iText generated pdf in Internet explorer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Open iText generated pdf in Internet explorer" Watch "Open iText generated pdf in Internet explorer" New topic
Author

Open iText generated pdf in Internet explorer

Himanshu Naini
Greenhorn

Joined: Mar 01, 2010
Posts: 4
Hi,
I have been able to create a PDF using iText libraries.
Now what I want is that this PDF should automatically open in IE instead of getting crated on one of the drives of the computer (version 6.0) as soon as it is created without any human involvement.

Please provide pointers or code snippet.

Thanks,
Himanshu
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
HI,
You can load it using JavaScript with document.URL = <PDF path> or redirect the Servlet request to the PDF path.
Himanshu Naini
Greenhorn

Joined: Mar 01, 2010
Posts: 4
Hi Samuel,
My problem is that I cannot invole servlets from the application I am working on.
Do you have any other ideas?

Regards,
Himanshu



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
The web app has no control over what happens to a downloaded on the client - that's entirely up to the browser and how the user has configured it. It may be saved automatically, it may get displayed automatically, or the user may be asked what to do with it each time.


Ping & DNS - my free Android networking tools app
Himanshu Naini
Greenhorn

Joined: Mar 01, 2010
Posts: 4
Hi Ulf,
I have my pdf data in a byte array made out of ByteArrayOutputStream that I created using iText.
What I want to know is how to push this byte array into an internet explorer page.
Please help.

Regards,
Himanshu
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
See the SimpleStream example in http://faq.javaranch.com/java/CodeBarnServlets for how to stream binary data to a client. As I said, there's no guarantee that the client will display the PDF in a browser window (or any window, actually).
Himanshu Naini
Greenhorn

Joined: Mar 01, 2010
Posts: 4
Hi Ulf,
Thanks for the prompt reply.
However I have another problem. I cannot invoke JSPs/Servlets from my application as it does not support .
So is there any other way of streaming other than JSPs or servlets.

Regards,
Himanshu
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Well, then what kind of application is this? You mentioned IE, so it was natural to assume a web app.
 
Consider Paul's rocket mass heater.
 
subject: Open iText generated pdf in Internet explorer