printing a file ...

  • Thread starter Thread starter giannis
  • Start date Start date
I want to press a button and print a specific image file.
What code must i write for this ?
I dont want to print a form or an image on a form ...
 
giannis said:
I want to press a button and print a specific image file. What code
must i write for this ?
I dont want to print a form or an image on a form ...


It takes some time to learn how to do it. The links I provided supply all
the information you need, not only how to print a Form. Sorry, I don't write
the code for you.


Armin
 
Is it correct ?
PrintDocument1.DocumentName = "c:\picture.jpg"

PrintDocument1.Print()
 
giannis said:
Is it correct ?
PrintDocument1.DocumentName = "c:\picture.jpg"

PrintDocument1.Print()


No. Add a handler to the 'PrintDocument' object's 'PrintPage' event and
place the code below in the event handler:

\\\
Using img As Image = Image.FromFile("C:\picture.jpg")
e.Graphics.DrawImage(img, ...)
End Using
///

Then simply call the 'PrintDocument''s 'Print' method.
 
giannis said:
Is it correct ?
PrintDocument1.DocumentName = "c:\picture.jpg"

PrintDocument1.Print()


You obviously don't bother reading the documentation. In order to learn, I
had to do it also on my own. Though, let me try to put it together:

This page shows how to print:

http://msdn2.microsoft.com/en-us/library/741a0ktc(vs.80).aspx

The principle is to use e.graphics to paint on it. In this case it's
"painted" on the printer, not on the screen. How to load an image and how to
paint it on a Graphics object is shown here:

http://msdn2.microsoft.com/en-us/library/sb2z5bb0.aspx

In your case, in the event handler of the PrintPage event, use the Graphics
object passed in e.graphics to paint the image.


Armin
 
Back
Top