EDN Admin
Well-known member
Can any please surgest how i can rewrite this code so that in my loop i print each page of the tif file.
What is happening at the moment is that the i go through the loop for each page however i only print the last page when i recall the document.print()
any ideas please.
<div style="margin:5px 20px 20px
<div class=smallfont style="margin-bottom:2px Code: <pre class=alt2 style="border-right:1px inset;padding-right:6px;border-top:1px inset;padding-left:6px;padding-bottom:6px;margin:0px;overflow:auto;border-left:1px inset;width:640px;padding-top:6px;border-bottom:1px inset;height:418px Public Sub PrintImage()
Dim document As New PrintDocument()
AddHandler document.PrintPage, AddressOf DocumentPrintPage
document.Print()
End Sub
Sub DocumentPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim img As Image
Dim intnumpages As Integer
img = System.Drawing.Image.FromFile("T:AppsPurchase Order Fax ProcessingArchive44050.Tif")
Dim pages As Integer = img.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page)
intnumpages = img.GetFrameCount(Imaging.FrameDimension.Page)
For i As Integer = 0 To pages - 1
img.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i)
e.Graphics.DrawImage(img, New Point(-20, -25))
Next
img.Dispose()
End Sub
Private Sub PrintImage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PrintImage()
End Sub[/code]
View the full article
What is happening at the moment is that the i go through the loop for each page however i only print the last page when i recall the document.print()
any ideas please.
<div style="margin:5px 20px 20px
<div class=smallfont style="margin-bottom:2px Code: <pre class=alt2 style="border-right:1px inset;padding-right:6px;border-top:1px inset;padding-left:6px;padding-bottom:6px;margin:0px;overflow:auto;border-left:1px inset;width:640px;padding-top:6px;border-bottom:1px inset;height:418px Public Sub PrintImage()
Dim document As New PrintDocument()
AddHandler document.PrintPage, AddressOf DocumentPrintPage
document.Print()
End Sub
Sub DocumentPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim img As Image
Dim intnumpages As Integer
img = System.Drawing.Image.FromFile("T:AppsPurchase Order Fax ProcessingArchive44050.Tif")
Dim pages As Integer = img.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page)
intnumpages = img.GetFrameCount(Imaging.FrameDimension.Page)
For i As Integer = 0 To pages - 1
img.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i)
e.Graphics.DrawImage(img, New Point(-20, -25))
Next
img.Dispose()
End Sub
Private Sub PrintImage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PrintImage()
End Sub[/code]
View the full article