in Service Manager

Custom Task for printing labels with Brother P-Touch device directly from SCSM Console

Do you know these small Brother P-Touch devices with which you can print labels in quite every manner? These devices are pretty widespread in Switzerland and many IT departments use them to print labels which they stick on a device and contain serial number, IP address and/or other key facts of this specific device. A customer for which I am developing a small asset management extension for Service Manager is also using such a device.

You can imagine that customers would like a solution where the employees could print such labels directly from Service Manager without having to use any other 3rd party solution. This would save the IT department a lot of time compared to the solution they work with now, where all assets reside in a Microsoft Access database which was connected to the Brother P-Touch Editor software. So I tried to figure out how this could be done and the solution I came up with looks like the following:

P-Touch Print SCSM Form

Pretty unspectacular 🙂 I discovered that Brother provides a SDK to communicate with the P-Touch devices programmatically. So creating a new Task which implements this functionality did the trick. But of course I still had to develop a custom assembly file which does all the printing magic and which I could reference by my new label printing task.

Brother provides some pretty good code samples together with their SDK. After installing b-PAC SDK for developers you can print to your P-Touch device from SCSM console by using the following C# code.

Note that b-PAC client component is not yet compatible with Windows 8. So you are not able to run any of the sample projects downloaded with the SDK. Also the application which is implementing your printing code has to be compiled for x86. x64 applications are not yet supported by Brother and in case of SCSM you therefore have to do a x86 installation of your console.

As you see, there is no printer defined in this snippet. All the information you need for printing a label is stored in the template which you have to create with P-Touch Editor software before. This makes it pretty easy to change printer and other label definitions without changing the code. As you see in the code listing above, it is possible to define an ID for each field within a label template. This is needed to map the object properties to the fields of the label for printing.

P-Touch Editor

However it was not that simple to get it working with SCSM. To make use of the SDK you have to reference a external DLL file provided by Brother which contains all the magic to be able to directly print to your P-Touch device.

Unfortunately it was not enough to just reference the external DLL in my new assembly and to include the DLL in the management pack bundle. I got the following exception in SCSM console when I tried to print a label

System.IO.FileNotFoundException: Could not load file or assembly ‘Interop.bpac, Version=, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
File name: ‘Interop.bpac, Version=, Culture=neutral, PublicKeyToken=null

After a while of trial and error I tried to embed the external DLL in my assembly rather than referencing it. And guess what, it worked. There is a very nice tutorial found on which describes how to embed managed and unmanaged DLL files into your own assembly.

So once I had a working assembly, I had to create a task to reference it. Do not forget to add a category for your Management Pack, otherwise your new task will never be visible to the users.
The third argument within the task definition is used to check what label has to be printed by the assembly. In my case this could be Printer or Scanner since the labels for these two assets differ.

Of course the newly created assembly has to be referenced in the Management Pack and we want to give the task a shiny new icon 🙂

Finally, to be able to print a label directly from SCSM console, the following requirements must be fulfilled on the client computer:

  • x86 SCSM Console has to be installed (no x64 applications are supported by the Brother b-pac SDK)
  • Install Brother P-Touch Printer
  • Install Brother b-PAC Client Component

Et voilà, printing labels for your devices is just one click away 🙂


Write a Comment


  1. Thanks for writing and sharing the article. How do you know the attributes of “C:SourceBrotherTest.lbx” template fil? I am getting null reference exception while accessing the attributes.

    • Hi Tariq
      Are you referring to attributes like DisplayName, WarrantyUntil, etc? These are specified directly in the label template. If I remember correctly you should be able to specify kind of a name for each object placed on your label. You can then get objects on your label by using doc.GetObject(“WarrantyUntil”).Text where doc is your label template.
      Hope this helps!