【问题标题】:Printing to a Brother printer from VB2013.net using the brother SDK使用 Brother SDK 从 VB2013.net 打印到 Brother 打印机
【发布时间】:2015-11-26 14:12:53
【问题描述】:

我有一些我认为应该打印到我兄弟打印机的代码,但它似乎什么也没做。快把我逼疯了!!

请大家有什么想法

    Dim PrinterName As String = ComboBox1.Text
    If PrinterName.Contains("Brother") Then
        Dim objDoc As bpac.Document
        objDoc = CreateObject("bpac.Document")
        Dim STRlbl As String = "C:\BarcodeScans\Application\Label.lbx"

        If (objDoc.Open("C:\BarcodeScans\Application\Label.lbx")) Then
            objDoc.GetObject("objCompany").Text = Txtbox1.Text
            objDoc.GetObject("objName").Text = Txtbox2.Text
            objDoc.SetPrinter(PrinterName, True)
            objDoc.StartPrint(STRlbl, PrintOptionConstants.bpoDefault)
            objDoc.PrintOut(1, PrintOptionConstants.bpoDefault)
            objDoc.EndPrint()
            objDoc.Close()
        End If

它不会失败或错误,它应该按顺序遍历每一行,它只是不打印。 通过 USB 直接连接到 Brother 打印机的我的 PC 上的标签/模板打印效果很好。打印机是 PT-9700PC

我被难住了。

【问题讨论】:

    标签: printing vb.net-2010


    【解决方案1】:
    Imports bpac
    Imports System.Drawing.Printing
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim pkInstalledPrinters As String
    
            ' Find all printers installed
            For Each pkInstalledPrinters In _
                PrinterSettings.InstalledPrinters
                ComboBox1.Items.Add(pkInstalledPrinters)
            Next pkInstalledPrinters
    
        End Sub
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim PrinterName As String = ComboBox1.Text
            Debug.Print(PrinterName.ToString)
            If PrinterName.Contains("Brother") Then
                Dim objDoc As bpac.Document
                objDoc = CreateObject("bpac.Document")
                Dim STRlbl As String = "C:\Users\...\UPC-A.lbx"
                If (objDoc.Open(STRlbl)) Then
                    objDoc.GetObject("tUPC-A").Text = TxtBox1.Text
                    objDoc.GetObject("tRetail").Text = TxtBox2.Text
                    objDoc.GetObject("tBarCode").Text = TxtBox3.Text
                    objDoc.SetPrinter(PrinterName, True)
                    objDoc.StartPrint(STRlbl, PrintOptionConstants.bpoDefault)
                    objDoc.PrintOut(1, PrintOptionConstants.bpoDefault)
                    objDoc.EndPrint()
                    objDoc.Close()
                End If
            End If
        End Sub
    
        Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ComboBox1.Text <> "" Then
                Button1.Enabled = True
            End If
        End Sub
    
    End Class
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多