to print the complete client area of a scrollable form, even if the form has been resized.
嘗試PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
這裏的另一種方式,將打印任何形式的部分是在屏幕上可見:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CaptureScreen()
PrintDocument1.DefaultPageSettings.Landscape = True
PrintDocument1.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0)
PrintDocument1.Print()
End Sub
Dim memoryImage As Bitmap
Private Sub CaptureScreen()
Dim myGraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)
End Sub
Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim pagerec As New RectangleF(e.PageSettings.PrintableArea.X, e.PageSettings.PrintableArea.Y, e.PageSettings.PrintableArea.Height, e.PageSettings.PrintableArea.Width)
e.Graphics.DrawImage(memoryImage, pagerec, New Rectangle(Me.Location, Me.Size), GraphicsUnit.Pixel)
End Sub
親愛@tinstaafl和別人的尊重的成員, 我已經嘗試過上述方法。 它不能正常工作,如下面的屏幕截圖網站所示: [http://s335.photobucket.com/user/blakeex/media/notcomplete-1.png.html] 你能否提出一個替代方案或讓我錯過了一步? – user2150279
我添加了一個替代我的答案。 – tinstaafl