views:

3155

answers:

4

I have an Asp.Net 1.1 application that uses the following code to write out an image file to a pop up web page.

    Response.ContentType="image/tiff"   'Only for Tif files
    Dim objStream As Object
    objStream = Server.CreateObject("ADODB.Stream")
    objStream.open()
    objStream.type = 1
    objStream.loadfromfile(localfile)
    Response.BinaryWrite(objStream.read)

I'm testing this out with TIF files. The files are being displayed correctly in IE6 and Safari but in IE7 they are not displaying and nothing seems to be returning to the web page. Files with jpg, gif extensions are being displayed properly. What might be the problem here?

A: 

Have you tried setting the Content-Disposition to Inline?

Response.AppendHeader("Content-Disposition", "inline");
Michael Stum
A: 

Yeah tried it just now. Doesn't work. Is it something to do with tiff having 4 letters instead of 3. I read somewhere that IE7 doesn't support 4 letter extensions.

Daud
+1  A: 

Well, it depends on your audience. But ideally, to support legacy browsers, you shouldn't assume they can handle a TIFF.

At the very least, load the TIFF, select the first frame (page), do a DrawImage into a new bitmap, save the bitmap as JPG to a memory stream, and send that to Response.

If you're not familiar with .NET's GDI+ image manipulation or that sounds hard, please see http://www.bobpowell.net/faqmain.htm for advice. Each one of these steps can be done with just a few lines of code. If you don't already know GDI+, it's worth learning for any web developer. That might make doing this 'the hard (but safe) way' worth it for the education alone. And if you already know how, it won't take but 1/2 hour.

If you must display multipage TIFFs, and you want the user to control which pages to see, you'll have to create a user interface to set the page number. If you're trying to display multiple TIFFs per page, that might get non-trivial, so consider displaying all the tiff #1 pages on the first web page, or, allowing them to view subsequent tiff pages by linking to another web page with prev/next tiff page buttons. It should be a generic page that accepts the filename and current page numbers (prev/next buttons would point to itself with +/- one page number) as URL parameters.

If you know you'll only be showing text documents instead of photographs, try sending single-frame GIFs instead of TIFFs to the browser for less Jpegginess on the text. But beforewarned - photos can look pretty bad a GIF.

FastAl
A: 

Can you please provide the entire code?

Thanks