08-10-17, 12:35 PM
PHP كود :
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim recHeight As Integer = e.PageSettings.PrintableArea.Height / 4
Dim recWidth As Integer = e.PageSettings.PrintableArea.Width / 3
Dim i As Integer = 1
Dim img As Image = Nothing
Dim z As New Size(recWidth, recHeight)
For y = 0 To 3
For x = 0 To 2
If i = 1 Then img = getCard(z, PictureBox1.Image, "Text1", Today.ToLongDateString)
If i = 2 Then img = getCard(z, PictureBox1.Image, "Text2", Today.ToLongDateString)
If i = 3 Then img = getCard(z, PictureBox1.Image, "Text3", Today.ToLongDateString)
If i = 4 Then img = getCard(z, PictureBox2.Image, "Text4", Today.ToLongDateString)
If i = 5 Then img = getCard(z, PictureBox2.Image, "Text5", Today.ToLongDateString)
If i = 6 Then img = getCard(z, PictureBox2.Image, "Text6", Today.ToLongDateString)
If i = 7 Then img = getCard(z, PictureBox3.Image, "Text7", Today.ToLongDateString)
If i = 8 Then img = getCard(z, PictureBox3.Image, "Text8", Today.ToLongDateString)
If i = 9 Then img = getCard(z, PictureBox3.Image, "Text9", Today.ToLongDateString)
If i = 10 Then img = getCard(z, PictureBox4.Image, "Text10", Today.ToLongDateString)
If i = 11 Then img = getCard(z, PictureBox4.Image, "Text11", Today.ToLongDateString)
If i = 12 Then img = getCard(z, PictureBox4.Image, "Text12", Today.ToLongDateString)
e.Graphics.DrawImage(img, New Point((x * recWidth), (y * recHeight)))
i += 1
Next
Next
End Sub
Function getCard(ByVal z As Size, ByVal img As Image, ByVal t1 As String, ByVal t2 As String) As Image
Using b As New Bitmap(z.Width, z.Height)
Using g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
g.DrawImage(img, 20, 30)
g.DrawString(t1, New Font("Arial", 10, FontStyle.Bold), Brushes.Blue, New Point(30, 70))
g.DrawString(t2, New Font("Arial", 10, FontStyle.Bold), Brushes.Brown, New Point(30, 90))
Return b.Clone
End Using
End Using
End Function
