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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
COBOLdinosaurCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.