2

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.

MarZab
  • 2,543
  • 21
  • 28
Tariq
  • 2,274
  • 4
  • 24
  • 40

1 Answers1

1

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");
MarZab
  • 2,543
  • 21
  • 28