Problem printing image presented via Response.BinaryWrite

 I have an ASP application that prints images associated with database records.  When a record is displayed, my code retreives the filename.  The filename is then passed to a helper script that actually loads the image into a buffer and does some massaging on it.  The helper script then outputs the image using Response.BinaryWrite.

  The helper code looks like this: (oIH is an object that does image manipulations on its Buffer member)

         ...
         Call oIH.Resize_Image(iHeight, iWidth, 1)
         Call oIH.Create_Buffer(2,100,0)
         
         Response.ContentType = "image/jpeg"
         Response.BinaryWrite oIH.Buffer
         Response.End

  The display code looks like:
        <img style="border: 1px solid #000080;" src="Utility_ImageHelper.asp?file=<%=sFileName%>&Grayscale=0&Height=200"></img>

         
  This code works fine for displaying the image in the browser window.  But, when I print the page from the browser (IE), instead of the image I get the little "red X" icon indicating the picture did not load.  Does anyone know why IE can retrieve it for display, but not for printing?

Thanks,
  Andy
LVL 1
andrewcrAsked:
Who is Participating?
 
COBOLdinosaurConnect With a Mentor Commented:
If the image is left in the buffer it is not going to print.  It has to go into the temporary internet files.  The browser does not print from memory it build the print data stream from the cache.

Cd&
0
 
COBOLdinosaurCommented:
It is not a conventional file, so it probably needs an external driver of some kind.  The format of data for a computer screen and for a printer are very different.  When you print from the browser and most other apps.  The cached files for the page are process through the print drivers to produce a data stream that the printer can interpret.  Is the buffered image even being cached?  If it is, is it in a format that the OS recognizes? Does it need an external driver or DLL for conversion to print format?

What does the documenttation on teh helper script say about printing?

Cd&
0
 
andrewcrAuthor Commented:
 I should point out that the images are embedded in the HTML page.  (In an <img> tag as shown above.)  Thus, it's up to the browser to interpret and render the image in both the display and print cases.  The images are in standard .jpg format and shouldn't require drivers or DLLs beyond what IE normally uses.

  A co-worker wrote the helper script, but it's a standard method of returning an image that's stored in a buffer.  There are dozens of similar examples showing how to display an image retrieved from a BLOB datdabase column available on the web:  First, the Response object returns information about the file type to the browser via
        Response.ContentType = "image/jpeg"
 and then it pushes the actual image bits via
        Response.BinaryWrite oIH.Buffer
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
andrewcrAuthor Commented:
 Hmm, interesting.  I'll take a look at the cache and let you know what I find....

Andy
0
 
COBOLdinosaurCommented:
I don't know what they found in the cache, but as they did not come back they must have it solved.  So points to me unless they come back to indicate otherwise IMHO..

Cd&
0
 
andrewcrAuthor Commented:
 I apologize for my long absence -- I got called away to work on other things and hand't gotten back to this. COBOLdinosaur's comments are helpful -- I'll work on this today and see if I can get it resolved.

  Thanks for your patience.

Andy
0
 
andrewcrAuthor Commented:
 That solved it.

  It's an odd thing -- on certain configurations, it worked fine already.  But, allowing the images to be cached (in the temporary internet folder) made it work in the other cases too.

  Also, I've added a few more points for your patience.  Thanks for your help.

Andy
0
 
COBOLdinosaurCommented:
Glad I could help.  Thanks for the A. :^)

Cd&
0
All Courses

From novice to tech pro — start learning today.