设置后,VB .NET WinFormApplication打印失败横向模式

时间:2013-07-18 08:51:47

标签: vb.net printing landscape preview

我正在使用VB .NET编程,我想在横向模式下打印WinFormsApplication,因为纵向模式无法正常使用。

我已将横向模式设为true。您可以参考以下代码:

    Private Sub PrintAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    Handles PrintAll.Click
    PrintForm1.Form = Me
    PrintDocument1.DefaultPageSettings.Landscape = True
    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.FullWindow)
    PrintDialog1.ShowDialog()
    End Sub

结果如下图所示 http://s335.photobucket.com/user/blakeex/media/notcomplete.png.html 任何人都可以分享一些提示或指南吗?

1 个答案:

答案 0 :(得分:0)

  

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