• 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

Not able to open PDFs for IE7

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What error do you get in IE 7?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic