Public Class FormQR

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tmpx As Single
        Dim tmpy As Single
        myp.PageUnits = VBprinter.VB2008Print.PageExportUnit.CentiMeter
        myp.NewDoc()
        myp.NewPage()
        Dim mymargin As Integer
        Dim myfont As New Font("宋体", 12)
        Dim mytxt As String
        Dim mywidth As Single
        Dim myheight As Single
        mytxt = "VB2008Print组件打印二维码测试，快用手机扫描试试，看看能不能扫描出来"
        myp.DrawTitle(mytxt, New Font("黑体", 18, FontStyle.Bold), Color.Red)
        mymargin = 0
        mytxt = "以margin为0打印二维码"

        tmpy = myp.Currenty
        myp.DrawText(mytxt, myfont)
        tmpx = myp.Currentx
        myp.NewRow(myp.LastDrawTextHeight)
        mywidth = myp.PaperPrintWidth / 4
        myheight = mywidth
        myp.DrawBarZxing(TextBox1.Text, VBprinter.VB2008Print.BarcodeFormat.QR_CODE, mywidth, myheight, Color.Black, Color.White, mymargin)
        'myp.NewRow(myheight)
        mytxt = "以margin为4打印二维码"
        mymargin = 4
        myp.Currenty = tmpy
        myp.Currentx = myp.PaperPrintWidth / 2
        myp.DrawText(mytxt, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.Currentx = myp.PaperPrintWidth / 2
        myp.DrawBarZxing(TextBox1.Text, VBprinter.VB2008Print.BarcodeFormat.QR_CODE, mywidth, myheight, Color.Black, Color.White, mymargin)
        myp.NewRow(myheight)



        mymargin = 0
        mytxt = "以margin为0打印二维码(画外边框）"
        myp.DrawText(mytxt, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        mywidth = myp.PaperPrintWidth / 4
        myheight = mywidth
        myp.DrawBarZxing(TextBox1.Text, VBprinter.VB2008Print.BarcodeFormat.QR_CODE, mywidth, myheight, Color.Red, Color.White, mymargin)
        myp.DrawRect(myp.Currentx, myp.Currenty, mywidth, myheight, Color.Blue, 0.5)
        myp.NewRow(myheight)
        mytxt = "以margin为4打印二维码（画外边框）"
        mymargin = 4
        myp.DrawText(mytxt, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.DrawBarZxing(TextBox1.Text, VBprinter.VB2008Print.BarcodeFormat.QR_CODE, mywidth, myheight, Color.Blue, Color.White, mymargin)
        myp.DrawRect(myp.Currentx, myp.Currenty, mywidth, myheight, Color.Red, 0.5)
        myp.NewRow(myheight)
        mytxt = "用谷歌的ZXxing.NET还可以打印一维码，下面打印EAN13码"
        myp.DrawText(mytxt, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.DrawBarZxing("123456789012", VBprinter.VB2008Print.BarcodeFormat.EAN_13, mywidth * 2, myheight, Color.Black, Color.White, 0)
        myp.NewRow(myheight)
        mytxt = "用谷歌的ZXxing.NET还可以打印一维码，下面打印EAN8码"
        myp.DrawText(mytxt, myfont)
        myp.NewRow(myp.LastDrawTextHeight)
        myp.DrawBarZxing("1234567", VBprinter.VB2008Print.BarcodeFormat.EAN_8, mywidth * 2, myheight, Color.Black, Color.White, 0)
        myp.EndDoc()
    End Sub
End Class