• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to open PDFs for IE7

 
priya Anand
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34207
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error do you get in IE 7?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I seem to recall that some browsers insist on having the content-length set correctly for PDFs.

Bill
 
priya Anand
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34207
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic