Am having problems printing a stored jpg file. I can load it rotate it save it but when it comes to printing it i just get a small portion of the image. . Note opening the saved portion file "rotated.jpg" contains the entire image. Here is the code
Imports System.Drawing.Printing
Imports System.Drawing.Image
Public Class Form1
Private WithEvents DialogsPrintDocument As PrintDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub DialogsPrintDocument_QueryPageSettings(ByVal sender As Object, ByVal e As _
System.Drawing.Printing.QueryPageSettingsEventArgs) _
Handles DialogsPrintDocument.QueryPageSettings
e.PageSettings.Landscape = True
End Sub
Private Sub DialogsPrintDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles DialogsPrintDocument.PrintPage
Dim img As Image
img = Image.FromFile("C:\xxx.jpg")
img.RotateFlip(RotateFlipType.Rotate180FlipNone)
e.HasMorePages = False
e.Graphics.DrawImage(img, New Point(0, 0))
img.Save("C:\rotated.jpg")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DialogsPrintDocument = New PrintDocument
With PrintDialog1
.AllowCurrentPage = False
.AllowPrintToFile = False
.AllowSelection = False
.AllowSomePages = False
.Document = DialogsPrintDocument
.PrinterSettings.DefaultPageSettings.Margins.Top = 25
.PrinterSettings.DefaultPageSettings.Margins.Bottom = 25
.PrinterSettings.DefaultPageSettings.Margins.Left = 25
.PrinterSettings.DefaultPageSettings.Margins.Right = 25
End With
If PrintDialog1.ShowDialog = DialogResult.OK Then
DialogsPrintDocument.PrinterSettings = PrintDialog1.PrinterSettings
strPrintRecord = TextBox1.Text
DialogsPrintDocument.Print()
End If
End Sub
End Class
Imports System.Drawing.Printing
Imports System.Drawing.Image
Public Class Form1
Private WithEvents DialogsPrintDocument As PrintDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub DialogsPrintDocument_QueryPageSettings(ByVal sender As Object, ByVal e As _
System.Drawing.Printing.QueryPageSettingsEventArgs) _
Handles DialogsPrintDocument.QueryPageSettings
e.PageSettings.Landscape = True
End Sub
Private Sub DialogsPrintDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles DialogsPrintDocument.PrintPage
Dim img As Image
img = Image.FromFile("C:\xxx.jpg")
img.RotateFlip(RotateFlipType.Rotate180FlipNone)
e.HasMorePages = False
e.Graphics.DrawImage(img, New Point(0, 0))
img.Save("C:\rotated.jpg")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DialogsPrintDocument = New PrintDocument
With PrintDialog1
.AllowCurrentPage = False
.AllowPrintToFile = False
.AllowSelection = False
.AllowSomePages = False
.Document = DialogsPrintDocument
.PrinterSettings.DefaultPageSettings.Margins.Top = 25
.PrinterSettings.DefaultPageSettings.Margins.Bottom = 25
.PrinterSettings.DefaultPageSettings.Margins.Left = 25
.PrinterSettings.DefaultPageSettings.Margins.Right = 25
End With
If PrintDialog1.ShowDialog = DialogResult.OK Then
DialogsPrintDocument.PrinterSettings = PrintDialog1.PrinterSettings
strPrintRecord = TextBox1.Text
DialogsPrintDocument.Print()
End If
End Sub
End Class