2016-07-06 101 views
-1

Syncfusion条码控制文本我有这样的代码:犯规出现在打印BMP VB NET

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条形码控制时,它生成的很好,它显示条形码,但是当我打印而不是条形码时什么也不是。

它可能是什么?

+0

BMP看起来有效:添加PictureBox并将其图像设置为BMP和.Refresh()它。看上去不错?也许是因为图像是32bpp ....打印机不能真正使用'alpha',请尝试24bpp。我不知道,只是一个猜测。 – ABuckau

+0

一切都很好用bmp。我真的不知道什么是错的。如果我把文本框,而不是syncfusion组件,并通过将文本框的字体属性更改为打印条形码的条形码字体来生成条形码。但只要我将值传递给sfbarcode1,尽可能在屏幕上显示条形码,尽可能打印条形码。惊人。 –

回答

0

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

'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

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

+0

你好。 ToImage不是SfBarcode的成员。输出这个错误。会是什么呢? –

+0

条码图像转换支持仅适用于最新版本(14.2.0.26),请您更新至最新版本并获得此支持。 https://www.syncfusion.com/downloads/latest-version – Karthikeyan