简体   繁体   中英

Using custom template files with bpac API (Brother label printer API) in C#

I designed a layout file using P-touch Editor 5.1 and saved it as P-touch layout(.lbx) file. It is not working in my C# project.

I am unable to set barcode data and the text lable in my C# project while using this layout file.

My problem is to set the attributes in the C# program. How can I find the attributes of the template? The following code is not working:

const string TEMPLATE_DIRECTORY = @"C:\Program Files (x86)\Brother bPAC3 SDK\Templates\newCustomTemplate.lbx";
bpac.DocumentClass doc = new DocumentClass();
if(doc.Open(templatePath) != false)
{
 doc.SetBarcodeData(253654789, "Apple iPhone");
 //Rest of the code
 ......
}

The printed lable does not contain the new data. It print the same data as set in the templete at design time.

Any help will be appreciated.

First off, you need to give names to each element you put on the tag in P-touch. (Right click, last tab). When you are addressing these fields you can use

doc.GetObject("objCompany").Text = txtCompany.Text;

for any fields except for some barcodes (CODE128/EAN128), that you need to address with their index, you can get their index with:

bc = doc.GetBarcodeIndex("barcodename")

then you can use

doc.SetBarcodeData(bc, "Apple iPhone");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM