在打印BMP VB NET时,不会出现Syncfusion条形码控制文本

时间:2016-07-06 10:02:51

标签: vb.net printing barcode syncfusion

我有这段代码:

 Private Sub BuildCode()
    Dim barcode As String = TextBox1.Text + "%" + TextBox2.Text + "&" + TextBox6.Text + "*"
    'TextBox3.Text = barcode
    SfBarcode1.Text = barcode
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    BMP = New Bitmap(GroupBox1.Width, GroupBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
    'BMP.SetResolution(300, 300)
    GroupBox1.DrawToBitmap(BMP, New Rectangle(0, 0, GroupBox1.Width, GroupBox1.Height))
    Dim pd As New PrintDocument
    Dim pdialog As New PrintDialog
    AddHandler pd.PrintPage, (Sub(s, args)
                                  args.Graphics.DrawImage(BMP, 0, 0)
                                  args.HasMorePages = False
                              End Sub)
    pdialog.ShowDialog()
    pd.PrinterSettings.PrinterName = pdialog.PrinterSettings.PrinterName
    pd.Print()
End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    BuildCode()
End Sub

如果我让textbox1控制其打印条形码。当我为syncfusion条形码控制赋值时,它构建正常,它显示条形码,但是当我打印而不是条形码时什么都没有。

它可能是什么?

1 个答案:

答案 0 :(得分:1)

我创建了一个解决方法示例,用于将条形码导出为图像并将图像插入到组框中并打印组框控件供您参考,请参阅以下代码段和示例以获取更多详细信息。

   'initialize the barcode control 
    Dim barcode As SfBarcode = New SfBarcode() 

    'set the barcode symbology type 
    barcode.Symbology = BarcodeSymbolType.Code128A 

    'set the input text 
    barcode.Text = TextBox1.Text 

    'export the barcode control as image 
    PictureBox1.Image = barcode.ToImage(PictureBox1.Size) 

示例链接: http://www.syncfusion.com/downloads/support/forum/124890/ze/BarcodeVb1482679502

请你试试这个,让我知道这是否符合你的实际要求。