Reputation: 2344
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.
Upvotes: 2
Views: 2693
Reputation: 2658
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");
Upvotes: 1