Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to print an Image

Avatar of picsnet
picsnet asked on
.NET Programming
7 Comments1 Solution402 ViewsLast Modified:
Hello, I have a windows service with a tcp listener that receives order numbers and then retreives a report over a web service as an image... It can be anything... Png, Tiff, whatever.  Anyways I get the image as a byte array.  

I want to send that image to the printer in a nice easy elegant way.  If I just send the byte array to the printer using sockets... I get nothing but garbage.  I don't know really understand or know how printing works at anything more than the highest levels.  Here is my code where I'm ready to print.  The part where i was using sockets is commented out.  I have another part there where I create an Image object from the byte array.  

Please shed some light for me on a nice way to send this Image object or byte array to the printer.  I don't think importing system.windows.forms and using a picturebox is a very elegant way to go about it though it'd probably be simplest.  

 If objBytes.Length > 0 Then

          Dim objStream As New MemoryStream(objBytes)
          Dim objImage As Image = Image.FromStream(objStream)

          'objSocket = New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)

          'If objSocket.Connected Then
          '  objSocket.SendTo(objBytes, 0, objBytes.Length, Sockets.SocketFlags.None, objEndPoint)
          'End If

        End If

Thanks, Tony
Avatar of Fernando Soto
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers