A
apple
i try to print image file in a directory using PrintDocument. It will raise
printPage event to draw image to the printer. The file will be deleted
after print and the directory will be checked every second to get new file
inside it.
Where should i do the delete function? The way to print image is get from
msdn. Can tell me where can i refer to other better ways to print the
image file.
Thank you.
Public fileName As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Sub printImage(ByVal fileName As String)
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As
PrintPageEventArgs)
' Draw a picture.
ev.Graphics.DrawImage(Image.FromFile(fileName),
ev.Graphics.VisibleClipBounds)
' Indicate that this is the last page to print.
ev.HasMorePages = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim dir As New DirectoryInfo("c:\dir")
Dim fi As FileInfo() = dir.GetFiles()
Dim fitemp As FileInfo
For Each fitemp In fi
fileName = fitemp.FullName
printImage(fileName)
Next
End Sub
___
Newsgroups brought to you courtesy of www.dotnetjohn.com
printPage event to draw image to the printer. The file will be deleted
after print and the directory will be checked every second to get new file
inside it.
Where should i do the delete function? The way to print image is get from
msdn. Can tell me where can i refer to other better ways to print the
image file.
Thank you.
Public fileName As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Sub printImage(ByVal fileName As String)
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As
PrintPageEventArgs)
' Draw a picture.
ev.Graphics.DrawImage(Image.FromFile(fileName),
ev.Graphics.VisibleClipBounds)
' Indicate that this is the last page to print.
ev.HasMorePages = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim dir As New DirectoryInfo("c:\dir")
Dim fi As FileInfo() = dir.GetFiles()
Dim fitemp As FileInfo
For Each fitemp In fi
fileName = fitemp.FullName
printImage(fileName)
Next
End Sub
___
Newsgroups brought to you courtesy of www.dotnetjohn.com