Public Class gz
    Private Sub gz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myp.InvalidatePreview()
    End Sub
    Private Sub myp_PrintDocument() Handles myp.PrintDocument
        '公章制作演示
        myp.NewPage()
        GZ1() '圆形公章

        GZ2() '椭圆公章

        GZ3() '发标专用章
    End Sub
    Private Sub GZ1()
        '圆形公章
        Dim myrect As New RectangleF(0, 0, myp.PaperPrintWidth / 3, myp.PaperPrintWidth / 3)
        Dim mypen As Pen = New Pen(Color.Red, 5)
        myp.DrawEllipse(mypen, myrect)
        Dim mybrush As New SolidBrush(Color.Red)
        myp.DrawFillFiveStar(New PointF(myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2), myrect.Width / 6, mybrush)
        Dim myfont As New Font("仿宋_GB2312", 22, FontStyle.Bold)
        myp.DrawCircleText("圆形公章制作测试", myfont, myrect.Width / 2 - 8, New PointF(myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2), 38, mybrush)

        mypen.Dispose()
        mybrush.Dispose()
    End Sub

    Private Sub GZ2()
        '圆形公章
        Dim myrect As New RectangleF(myp.PaperPrintWidth / 2, 0, myp.PaperPrintWidth / 2, myp.PaperPrintWidth / 3)
        Dim mypen As Pen = New Pen(Color.Red, 5)
        myp.DrawEllipse(mypen, myrect)
        Dim mybrush As New SolidBrush(Color.Red)
        myp.DrawFillFiveStar(New PointF(myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2), myrect.Width / 6, mybrush)
        Dim myfont As New Font("仿宋_GB2312", 22, FontStyle.Bold)
        myp.DrawEllipseText("椭圆形公章制作测试", myfont, myrect.Width / 2 - 8, myrect.Height / 2 - 8, New PointF(myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2), 28, mybrush)

        mypen.Dispose()
        mybrush.Dispose()
    End Sub


    Private Sub GZ3()
        '发票专用章
        Dim myrect As New RectangleF(0, myp.PaperPrintWidth / 2, myp.PaperPrintWidth / 2, myp.PaperPrintWidth / 3)
        Dim mypen As Pen = New Pen(Color.Red, 5)
        myp.DrawEllipse(mypen, myrect)
        Dim mybrush As New SolidBrush(Color.Red)
          Dim myfont As New Font("仿宋_GB2312", 22, FontStyle.Bold)
        myp.DrawEllipseText("某某有限公司上海分公司", myfont, myrect.Width / 2 - 8, myrect.Height / 2 - 8, New PointF(myrect.Left + myrect.Width / 2, myrect.Top + myrect.Height / 2), 18, mybrush)
        Dim myformat As New StringFormat(StringFormat.GenericTypographic)
        myformat.Alignment = StringAlignment.Center
        Dim rect2 As RectangleF
        Dim h As Single
        Dim w As Single
        myfont = New Font("宋体", 14)
        h = 10

        w = myrect.Width - 30
        rect2 = New RectangleF(myrect.Left + myrect.Width / 2 - w / 2, myrect.Top + myrect.Height / 2, w, h)
        myp.DrawText("税号:123456789455662", rect2, myfont, Brushes.Red, myformat, 0)

        h = 50

        w = myrect.Width - 30
        rect2 = New RectangleF(myrect.Left + myrect.Width / 2 - w / 2, myrect.Top + myrect.Height - h, w, h)
        

        myfont = New Font("宋体", 18)
        myp.DrawText("发票专用章", rect2, myfont, Brushes.Red, myformat, 0)
        mypen.Dispose()
        mybrush.Dispose()
    End Sub
End Class