Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem printing image presented via Response.BinaryWrite

Posted on 2004-10-26
9
Medium Priority
?
377 Views
Last Modified: 2008-02-20
 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
0
Comment
Question by:andrewcr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12414028
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
 
LVL 1

Author Comment

by:andrewcr
ID: 12415439
 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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 1200 total points
ID: 12416245
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:andrewcr
ID: 12424491
 Hmm, interesting.  I'll take a look at the cache and let you know what I find....

Andy
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12749119
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
 
LVL 1

Author Comment

by:andrewcr
ID: 12754321
 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
 
LVL 1

Author Comment

by:andrewcr
ID: 12755175
 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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12755713
Glad I could help.  Thanks for the A. :^)

Cd&
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to count occurrences of each item in an array.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question