Public Class rotate

    Private Sub myp_PrintDocument() Handles myp.PrintDocument
        myp.NewPage()
        Dim myrect As New RectangleF(160, 70, 400, 500)
        Dim myfont As New Font("黑体", 13, FontStyle.Bold)
        Dim myformat = New StringFormat(StringFormat.GenericTypographic)
        myformat.Alignment = StringAlignment.Center
        myp.DrawCell("这是未旋转的打印结果", myrect, myfont, Color.Black, myformat, "1111", Color.Black)
        myp.Rotate(45, myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2) '以打印内容的中心点旋转４５度
        myp.DrawCell("在原位置以打印矩形大小的中心点为旋转中心旋转４５度的打印结果", myrect, myfont, Color.Blue, myformat, "1111", Color.Blue)

        myp.NewRow(myp.LastDrawTextHeight + myrect.Height)
        myrect = New RectangleF(myrect.X, myp.Currenty, myrect.Width, myrect.Height)
        myp.ResetTransform() '复原
        myp.DrawCell("这是未旋转的打印结果", myrect, myfont, Color.Black, myformat, "1111", Color.Black)
        myp.Rotate(45, myrect.Left, myrect.Top)
        myp.DrawCell("在原位置以打印矩形大小的左上角为旋转中心旋转４５度的打印结果", myrect, myfont, Color.Green, myformat, "1111", Color.Green)
        myp.Rotate(45, myrect.Left + myrect.Width, myrect.Top)
        myp.DrawCell("在原位置以打印矩形大小的右上角为旋转中心旋转４５度的打印结果", myrect, myfont, Color.Red, myformat, "1111", Color.Red)

        myp.NewRow(myp.LastDrawTextHeight + myrect.Height / 2)
        myrect = New RectangleF(myrect.X, myp.Currenty, myrect.Width, myrect.Height)
        myp.ResetTransform() '复原
        myp.DrawCell("这是未旋转的打印结果", myrect, myfont, Color.Black, myformat, "1111", Color.Black)
        myp.Rotate(45, myrect.Left, myrect.Top + myrect.Height)
        myp.DrawCell("在原位置以打印矩形大小的左下角为旋转中心旋转４５度的打印结果", myrect, myfont, Color.Green, myformat, "1111", Color.Green)
        myp.Rotate(45, myrect.Left + myrect.Width, myrect.Top + myrect.Height)
        myp.DrawCell("在原位置以打印矩形大小的右下角为旋转中心旋转４５度的打印结果", myrect, myfont, Color.Red, myformat, "1111", Color.Red)


        myrect = New RectangleF(1000, 70, 600, 700)
        myp.ResetTransform()
        myp.DrawImage(My.Resources.mybmp, myrect.X, myrect.Y, myrect.Width, myrect.Height, True)

        myp.Rotate(45, myrect.Left, myrect.Top)
        myp.DrawImage(My.Resources.mybmp, myrect.X, myrect.Y, myrect.Width, myrect.Height, True)



        myrect = New RectangleF(1000, 70 + myrect.Height * 1.5, 600, 700)
        myp.Rotate(45, myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2)
        myp.DrawImage(My.Resources.mybmp, myrect.X, myrect.Y, myrect.Width, myrect.Height, True)

    End Sub

    Private Sub rotate_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        myp.PageUnits = VBprinter.VB2008Print.PageExportUnit.CentiMeter '以１/10毫米为计量单位
        myp.InvalidatePreview()
    End Sub
End Class