_
Brushes.Black, 0, 0)
End Sub
End Sub
' m_elements contains classes that derive
' from PrintableElements
Private m_elements As ArrayList
m_elements.Add(New PrintableString("Tekst", 0, 0))
Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
For Each element As PrintableElement In m_elements
element.Draw(e.Graphics)
Next
End Sub
Of course if there are multiple pages, then there is more work involved.
Hope this helps
Jay
At last, it prints.
But (of course
) I have another question:
I used this code:
Private WithEvents PrintDocument1 As New
System.Drawing.Printing.PrintDocument()
Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
e.Graphics.DrawString("Tekst", New Font("Arial", 12, FontStyle.Bold),
Brushes.Black, 0, 0)
End Sub
How can I send printdata from outside the PrintPage eventhandler to the
eventhandler. Something like:
Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs, Tekst As String, x As Integer,
y
As Integer) Handles PrintDocument1.PrintPage
e.Graphics.DrawString(Tekst, New Font("Arial", 12, FontStyle.Bold),
Brushes.Black, x, y)
End Sub
Of course, this desn't work...
Marc
"Jay B. Harlow [MVP - Outlook]" <
[email protected]> schreef in
bericht Marc,
You are drawing on a bitmap, not on the document!
To draw on the document you need to handle the PrintDocument.PrintPage
event. This event has a PrintPageEventArgs parameter. The
PrintPageEventArgs
object has a Graphics property. You need to draw on this Graphics object
to
have it shown on the document you are attempting to print.
For a reasonable complete sample of using PrintDocument see: