3

我有一个文档,我想在打印时翻转/旋转 180 度。(这是由于打印机中标签纸的方向所致)。

有一个属性PrintDocument.PrinterSettings.LandscapeAngle,但它是只读的。

我认为这个属性受打印机驱动程序的影响,因此不是“可设置的”。

有没有一种很好的方法可以将打印件旋转 180 度而不必做任何太讨厌的事情?

4

4 回答 4

2

你要PrintDocument.DefaultPageSettings.Landscape

于 2009-01-09T20:56:31.317 回答
2

我想这取决于你定义为“任何太讨厌的东西”:-)

PrintDocument类有一个可供您使用的Graphics对象,该对象又具有一个TranslateTransformRotateTransform方法,可让您在需要的地方获取内容。

通常值得在操作图形对象之前对其进行复制,以便在完成后再次恢复它。

于 2009-10-27T09:42:57.317 回答
2

在 VB.NET 中打印表单并翻转/旋转 PrintDocument 并将 DefaultPageSettings 设置为横向

Dim WithEvents mPrintDocument As New PrintDocument
Dim mPrintBitMap As Bitmap
Private Sub m_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mPrintDocument.PrintPage
    mPrintBitMap.RotateFlip(RotateFlipType.Rotate90FlipNone)
    mPrintDocument.PrinterSettings.DefaultPageSettings.Landscape = True
    ' Draw the image centered.     
    Dim lWidth As Integer = e.MarginBounds.X + (e.MarginBounds.Width - mPrintBitMap.Width) \ 2
    Dim lHeight As Integer = e.MarginBounds.Y + (e.MarginBounds.Height - mPrintBitMap.Height) \ 2

    e.Graphics.DrawImage(mPrintBitMap, lWidth, lHeight)
    ' There's only one page.   
    e.HasMorePages = False
End Sub
Private Sub B_print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_print.Click
    ' Copy the form image into a bitmap.    
    mPrintBitMap = New Bitmap(Me.Width, Me.Height)
    Dim lRect As System.Drawing.Rectangle
    lRect.Width = Me.Width
    lRect.Height = Me.Height
    Me.DrawToBitmap(mPrintBitMap, lRect)
    ' Make a PrintDocument and print.    
    mPrintDocument = New PrintDocument

    mPrintDocument.Print()

End Sub
于 2012-08-24T09:57:39.993 回答
1

您在将其分配给打印机 GDI 之前是否尝试过旋转它自己的图像?这就是我所做的:

                _currentPage = Image.FromStream((MemoryStream)_queue.Dequeue());
                pageHeight = _currentPage.Height;
                pageWidth = _currentPage.Width;

                if (pageHeight < pageWidth)
                {
                    _currentPage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    pageHeight = _currentPage.Height;
                    pageWidth = _currentPage.Width;                      

                }
于 2010-01-26T22:43:59.103 回答