I'm currently working on a software project that will use a Brother QL-800
  label printer. I chose to printer thanks to the presence of
  SDK documentation
  since I’m going to write a .NET Core WPF application that will handle the
  printer. The application is very simple, four input fields that shall be
  printed. 
  The SDK works well, it does what it’s supposed to do. The general feeling is
  that Brother actually created an SDK that was intended to be used.
  My approach was to create a template in Brother’s
  P-touch Editor software, and use the template (adding data to template)
  when printing. It’s probably possible to dynamically create the label in
  the API, but using a template is fast and easy. Every text field in the
  template is assigned an Object Name (e.g. “FieldName”). The object name
  is later used when printing. Below is a snippet of code which will print a
  label (29mm x 90mm) containing four text fields.
using bpac;
using System;
namespace QL800ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var doc = new DocumentClass();
            if (doc.Open("LabelTemplateBlack_29x90.lbx"))
            {
                // fill out fields in template
                doc.GetObject("FieldNumber").Text = "12345";
                doc.GetObject("FieldName").Text = "Gary Goodspeed";
                doc.GetObject("FieldDate").Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ;
                doc.GetObject("FieldNote").Text = "12345";
                // cut label when done
                doc.StartPrint("", PrintOptionConstants.bpoAutoCut);
                // print one copy
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                // we're done
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                Console.WriteLine("Template file not found");
            }
        }
    }
}
Comments
Post a Comment