我有一个文件需要在打印时翻转/旋转180度。(这是由于打印机标签纸的方向造成的)
有一个属性PrintDocument.PrinterSettings.LandscapeAngle
,但它是只读的。
我认为这个属性受打印机驱动程序的影响,因此不能“设置”。
是否有一种简便的方法可以将打印旋转180度,而不必做任何过于复杂的操作?
我有一个文件需要在打印时翻转/旋转180度。(这是由于打印机标签纸的方向造成的)
有一个属性PrintDocument.PrinterSettings.LandscapeAngle
,但它是只读的。
我认为这个属性受打印机驱动程序的影响,因此不能“设置”。
是否有一种简便的方法可以将打印旋转180度,而不必做任何过于复杂的操作?
您希望使用 PrintDocument.DefaultPageSettings.Landscape
来横向打印文档。
在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;
}