我有一份文件,我希望在打印时翻转/旋转180度。 (这是由于打印机中标签纸的方向)。

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

我认为此属性受打印机驱动程序的影响,因此无法“设置”。

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

有帮助吗?

解决方案

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

PrintDocument 课程有一个图形对象,您可以使用此对象,转过来有一个 TranslateTransform RotateTransform 方法,可以让你得到你的东西需要它们。

在操作之前,通常需要获取图形对象的副本,以便在完成后再将其恢复。

其他提示

打印表单并在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

你有没有尝试过将它分配给打印机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;                      

                }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top