File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Not able to open PDFs for IE7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not able to open PDFs for IE7" Watch "Not able to open PDFs for IE7" New topic
Author

Not able to open PDFs for IE7

priya Anand
Greenhorn

Joined: Mar 30, 2009
Posts: 20
Problem with opening PDF files on IE7.

It works fine on IE6 but does not work on IE7

This is my code snippet,

strURL.append("http://");
strURL.append(sessionValues.getiXOSServer());
strURL.append("/archive?get");
strURL.append("&contRep=" + invoice.getArchiveID());
strURL.append("&docId=" + invoice.getArchiveDocID());
strURL.append("&compId=data");
strURL.append("&pVersion=0045");

ServletOutputStream sos = resp.getOutputStream();

resp.setContentType("application/pdf");
resp.setHeader("Content-disposition", "inline;");

try
{
url = new URL(strURL.toString());
//debugger.print(strURL.toString());
huc = (HttpURLConnection)url.openConnection();
}
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30916
    
158

What error do you get in IE 7?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12822
    
    5
I seem to recall that some browsers insist on having the content-length set correctly for PDFs.

Bill
priya Anand
Greenhorn

Joined: Mar 30, 2009
Posts: 20
I dont get any error as such but a new tab opens and it is blank.

I am not sure about content length. Can you elaborate on that?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12822
    
    5
I am guessing that without a content-length, some browsers are unable to decide when they have gotten the entire PDF, thus they show a blank.

Therefore, you need to have a way to figure out the length before any response headers are sent - if the source is a File, thats easy.

Bill
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30916
    
158

And if it's not a file, you can store it in an in-memory string buffer. That way you know the size before writing it to the response.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12822
    
    5
in-memory string buffer


Not a string buffer please - a byte buffer since PDF's turn into garbage if you try to force the bytes into a string encoding.

See for example java.io.ByteArrayOutputStream to create an extensible byte buffer

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to open PDFs for IE7