質問

印刷時に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