>>> I want to print an ID card. I have one Windows Form that contains front
>>>
>>> and back side. The printer is printing both front and back side at a
>>> time. I am trying to send both sides at a time. But it is printing
>>> front side on one card and back side on second card. I want to print
>>> both sides in a same card.
> Yes, i have contacted about it.
>
[quoted text clipped - 29 lines]
>>>
>>> Raman.
Hello HKSHK,
Please help me out from this problem
I have 2 frames in windows form. From that i have created 2 bitmap
images.
When i call use this function only back side is printed and card is
strucked in the printer. But two pages are send to printer. but second
image is overwritted on frirst image. So second page does not contain
any thing.
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e
As Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
e.Graphics.DrawImage(Me.Print_ImageF, 0, 0)
e.HasMorePages=True
e.Graphics.DrawImage(Me.Print_ImageB, 0, 0)
End Sub
or
When i use this function both front side and back side is printed. but
both are printed in different card.
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrint.Click
page=1 ' Vriable to represent which page
For i = 1 To 2
PrintDocument1.Print() 'Print the document
page = page + 1
Next
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e
As Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
If page = 1 Then
e.Graphics.DrawImage(Me.Print_ImageF, 0, 0)
ElseIf page = 2 Then
e.Graphics.DrawImage(Me.Print_ImageB, 0, 0)
End If
End Sub
I have created these two images by following coding in btnPrint_Click
function. It is created before the print command is called.
'We make the form look pritty befor its picture
Application.DoEvents()
Me.Refresh()
Application.DoEvents()
'Get a Graphics Object from the form
Dim FormGF As Graphics = gbFront.CreateGraphics
'Create a bitmap from that graphics
Dim iFront As New Bitmap(gbFront.Width, gbFront.Height,
FormGF)
'Create a Graphics object in memory from that bitmap
Dim memGFront As Graphics = Graphics.FromImage(iFront)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = FormGF.GetHdc
Dim HDC2 As IntPtr = memGFront.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, gbFront.ClientRectangle.Width,
gbFront.ClientRectangle.Height, HDC1, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_ImageF = iFront.Clone()
'Clean Up
FormGF.ReleaseHdc(HDC1)
memGFront.ReleaseHdc(HDC2)
FormGF.Dispose()
memGFront.Dispose()
iFront.Dispose()
Dim FormGB As Graphics = gbBack.CreateGraphics
Dim iBack As New Bitmap(gbBack.Width, gbBack.Height,
FormGB)
Dim memGBack As Graphics = Graphics.FromImage(iBack)
Dim HDC3 As IntPtr = FormGB.GetHdc
Dim HDC4 As IntPtr = memGBack.GetHdc
'get the picture
BitBlt(HDC4, 0, 0, gbBack.ClientRectangle.Width,
gbBack.ClientRectangle.Height, HDC3, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_ImageB = iBack.Clone()
'Clean Up
FormGB.ReleaseHdc(HDC3)
memGBack.ReleaseHdc(HDC4)
FormGB.Dispose()
memGBack.Dispose()
iBack.Dispose()
> Hello Raman,
>
[quoted text clipped - 45 lines]
> >>>
> >>> Raman.