Solved

Problem printing image presented via Response.BinaryWrite

Posted on 2004-10-26
362 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
Question by:andrewcr
    8 Comments
     
    LVL 53

    Expert Comment

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

    Author Comment

    by:andrewcr
     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
    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
     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
     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
    Glad I could help.  Thanks for the A. :^)

    Cd&
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    When pages do not download correctly, and you don't know why, the first thing you do is to look at the HTML source code of that page, but not all the downloaded files appear always clearly. If your source includes a javascript that computes the name…
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    931 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now