【问题标题】:Syncfusion barcode control text doesnt appear at printing BMP VB NETSyncfusion 条码控制文本在打印 BMP VB NET 时不出现
【发布时间】:2016-11-08 08:17:33
【问题描述】:

我有这个代码:

 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 条码控件赋值时,它构建得很好,它显示了条码,但是当我打印而不是条码时什么都没有。

会是什么?

【问题讨论】:

  • BMP 看起来是否有效:添加 PictureBox 并将其图像设置为 BMP 和 .Refresh() 它。这看起来不错的样子?可能是因为图像是 32bpp....打印机不能真正使用 'alpha',试试 24bpp。我不知道,只是猜测。
  • bmp 一切正常。我真的不知道有什么问题。如果我放置文本框而不是同步融合组件并通过将文本框的字体属性更改为条码字体来生成条码,则它会打印条码。但是一旦我将值传递给 sfbarcode1 就不会打印条形码,尽管它会在屏幕上正确显示条形码。太棒了。

标签: vb.net printing barcode syncfusion


【解决方案1】:

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

   '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

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

【讨论】:

  • 你好。 ToImage 不是 SfBarcode 的成员。输出这个错误。会是什么?
  • 条码到图像的转换支持仅在最新版本 (14.2.0.26) 中可用,请您更新到最新版本并获得此支持。 syncfusion.com/downloads/latest-version
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-18
  • 1970-01-01
  • 2013-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-06
相关资源
最近更新 更多