Public Class zydy

    Private Sub myp_PrintDocument() Handles myp.PrintDocument
        MyPrint()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        myp.InvalidatePreview() '激发刷新事件，这会引发打印组件的PrintDocument事件

        '如果将上面的语句注释掉，用下面的语句，则是VB2008Print组件的另一种打印实现方法
        'myp.NewDoc()
        'MyPrint()
        'myp.EndDoc()
    End Sub
    Private Sub MyPrint()
        myp.NewPage()
        Dim tempx As Single
        Dim myfont As New Font("宋体", 14)
        Dim mys As String
        mys = "VB2008Print是一个使用非常灵活的打印控件，不仅具有强大的文本、图片、与表格打印功能"
        mys = mys & "，如果灵活使用，可以打印各种各样的复杂表格，不信请看本实例吧，您可以体会一下控件的强大功能。"
        myp.DrawText(mys, myfont, 0)
        myp.NewRow(myp.LastDrawTextHeight) '换新行
        myp.NewRow(50) '再加5毫米的间距，因为我将控件的PageUnits设置为CentiMeter,故控件的计量单位为1/100厘米
        Dim myformat As StringFormat = New StringFormat(StringFormat.GenericTypographic)
        myformat.Alignment = StringAlignment.Center '居中对齐
        myformat.LineAlignment = StringAlignment.Center
        myp.DrawText("下面是一个简历表格的演示", myp.PaperPrintWidth(), New Font("隶书", 20, FontStyle.Bold), Color.Blue, myformat, 0)
        myp.NewRow(myp.LastDrawTextHeight + 30)
        myfont = New Font("宋体", 12)
        Dim myfont2 = New Font("仿宋_GB2312", 12, FontStyle.Bold)
        Dim myh As Single = 110 '行高
        myp.DrawCell("姓名", 130, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("张  三", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("性别", 130, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("男", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("民族", 130, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("汉", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("学历", 130, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("本科", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        tempx = myp.Currentx '记住当前X位置
        myp.DrawCellImage(PictureBox1.Image, myp.Currentx, myp.Currenty, 350, 3 * myh, "1111", True, StringAlignment.Center, StringAlignment.Center)
        myp.Currentx = tempx '还原位置
        myp.DrawCell("这是我的相片，帅不，哈哈！", 350, 3 * myh, New Font("黑体", 13, FontStyle.Bold), Color.Blue, "0000", StringAlignment.Center, StringAlignment.Center, True, True, True, True, 6, Color.Transparent, Color.Black, 0)

        '下一行
        myp.NewRow(myh)
        myp.DrawCell("年龄", 130, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("32", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("出生年月", 230, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("1980年某月某日", 270, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("政治面貌", 230, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("群众", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        '下一行
        myp.Currenty = myp.Currenty + myh
        myp.Currentx = 0 '上面这两行其实用 myp.NewRow(myh)效果是一样的
        myp.DrawCell("联系地址", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("地球 亚洲 中华人民共和国 湖南省 株洲市 芦淞区 董家段 215信箱", 630, myh, myfont2, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Center, True, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("邮编", 230, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("412002", 170, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)


        '下一行
        myp.NewRow(myh)
        myp.DrawCell("移动电话", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("12345678901", 325, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("固定电话", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("0731-123456789", 335, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("邮箱", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("myyouping@139.com", 380, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        '下一行
        myp.NewRow(myh)
        myp.DrawCell("籍  贯", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("湖南 新化", 325, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("婚姻状态", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("未婚", 335, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("身份证" & vbCrLf & "号码", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("123456789012345678", 380, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        '下一行
        myp.NewRow(myh)
        myp.DrawCell("毕业学校", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("中南林业科技大学", 325, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("专业", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("会计", 265, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        myp.DrawCell("计算机证书", 230, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, False, 6, Color.White, Color.Black, 0)
        myp.DrawCell("高级程序员" & vbCrLf & "网络工程 师", 390, myh, myfont2, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, False, 6, Color.White, Color.Black, 0)

        '下一行
        myp.NewRow(myh)
        myh = 900
        myp.CellMargin = New System.Drawing.Printing.Margins(30, 30, 30, 30)
        myp.DrawCell("个  人  简  介", 170, myh, myfont, Color.Black, "1111", StringAlignment.Center, StringAlignment.Center, False, False, False, True, 6, Color.White, Color.Black, 0)
        mys = "热爱计算机，特别是程序设计，先后自学C#、PowerBuilder、Delphi、VB.NET、ASP等多种编程语言，名符其实的程序迷。"
        mys = mys & vbCrLf
        mys = mys & "1998年到2002年中南林业科技大学会计学专业"
        mys = mys & vbCrLf
        mys = mys & "2000年取得全国计算机等级考试二级（C语言）证书"
        mys = mys & vbCrLf
        mys = mys & "2000年取得CET4级证书"
        mys = mys & vbCrLf
        mys = mys & "2001年取得全国计算机等级考试三级（软件类）证书"
        mys = mys & vbCrLf
        mys = mys & "2001年取得中国计算机专业技术资格水平考试程序员级水平证书"
        mys = mys & vbCrLf
        mys = mys & "2002取得CET6及证书"
        mys = mys & vbCrLf
        mys = mys & "2003年取得高级程序员证书"
        mys = mys & vbCrLf
        mys = mys & "2005年取得数据库系统工程师证书"
        mys = mys & vbCrLf
        mys = mys & "2006年取得网络工程师证书"
        myp.DrawCell(mys, 1380, myh, myfont, Color.Black, "1111", StringAlignment.Near, StringAlignment.Near, True, False, False, False, 6, Color.White, Color.Black, 0)

        '其他内容
        myp.NewRow(myp.LastDrawTextHeight)
        myp.NewRow(30)
        myp.DrawLine(New Pen(New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, 0), Color.Blue, Color.Red), 12), 0, myp.Currenty, myp.PaperPrintWidth, myp.Currenty)
        myp.NewRow(30)
        myp.DrawText("这是简历的结束行")
        myp.NewRow(myp.LastDrawTextHeight)
        myp.NewRow(30)
        myp.DrawFillRectangle((New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, 0), Color.Green, Color.Blue)), 0, myp.Currenty, myp.PaperPrintWidth, 50)

    End Sub
End Class
