Integrate Printing With Production Processes
The first time you printed a label with Label LIVE you probably entered all text by typing it in manually. Then you tried adding a variable. To save time, you started importing bulk data using a spreadsheet or CSV file. Life was good.
The reality is spreadsheets can be error prone or slow down production processes. To further automate label printing you might consider a deeper integration with Label LIVE using URLs, the command line, or triggering print jobs using an API and network protocol like MQTT/HTTP. Don’t let these scare you! Follow this guide.
Automated Printing
Starting with Label LIVE version 2.4 you can automate printing labels by using special commands. You can try this today by creating and saving a label design. Add a variable and click the Data
> Integrate
button.
Oh, that's interesting... it looks like a website address. And you're not wrong. This is a URL (technically a URI) - and it describes a resource. In this case, the resource is "handled" by labellive://
which means, when your computer "opens" this resource, it opens Label LIVE and your favorite label printing app takes over from there.
The part after labellive://
is print
and that tells Label LIVE we're going to print a label. Everything after ?
are the options for printing. Since you clicked on the Integrate button inside your own design you'll see the full path to your saved design, any variables, the printer and the number of copies.
This works right out of the box. No, seriously, try it!
Behold, The Two-Click Integration
Click on "Copy Browser URL" and paste into your browser. You will get a prompt to "Open" Label LIVE.
Accept and... boom. Your label has printed. 🤯
Before we dive deeper, ask yourself...
Why and When To Integrate?
The biggest opportunity to integrate label printing is when variables are in use.
The idea is that you tell Label LIVE exactly what text to put inside your variables. This text might be label text such as ingredients, numbers for barcodes, pricing or weighing, or even a color for use in the design.
There are additional options to help control the printing. For example, you can set the number of copies, the destination printer, and even control if Label LIVE stays hidden or minimized.
Integration: 3 ways
There are three ways to integrate label printing with Label LIVE:
Simple URL - This looks like a website address but instead of starting with
https://
it starts withlabellive://
Opening this kind of URL (technically a URI) will automatically open Label LIVE and print the label. You can test this by pasting into a web browser. Additionally, these links can be placed inside a file with extension.lsb
. Opening a "lsb" should will instruct Label LIVE to process the contents of the file.Command Line - This is very similar to a URL, but is formatted for use using Terminal.app (macOS) or cmd (windows). Similar to clicking a URL, a command will open Label LIVE if it is not already open.
HTTP - This is the easiest way for developers to integrate label printing. You can either GET an image using a URL or POST a request that triggers a print job. Label LIVE must be open for this to work.
MQTT - This is for advanced users and is an efficient way to integrate label printing. You can publish a payload and subscribe to a status topic to know exactly when your label is printed. Label LIVE must be open for this to work.
If your current integration need involves a spreadsheet or CSV file you might be interested in batch imports:
Integration Options
Most integrations will use a similar format to trigger printing. Let's break down the URL into its basic parts. Each part is separated by an ampersand &
which effectively glues together the parts. Because the &
is considered special, any use of ampersands within the other options must be escaped using \&
.
labellive://print?design=sample-address-label&variables=NAME:'Jane Doe',ADDRESS:'123 Long Road',ADDRESS2:'Building 4',CITY:'Anytown',STATE:'ZX',ZIP:'12345'&printer=Preview&window=show&copies=1
Design
This is the name of the Label LIVE design file (lsc). This option is required. The design must be Pinned to the Home screen.
design=sample-address-label
Variables
This is a RJSON (relaxed JSON) representation of the label's variables. Use single quotes around whitespace. Use escaped single quotes \'
to use apostrophes within values.
variables=NAME:'Jane Doe',ADDRESS:'123 Long Road',ADDRESS2:'Building 4',CITY:'Anytown',STATE:'ZX',ZIP:'12345'
Rows/Skip
If you are integrating with a pre-loaded spreadsheet you may use the options rows
and skip
similar to how they are used on the Print tab. The use of "variables" will override "rows." Choose one or the other.
Printer
The default printer is whatever was last used in the open design. Print Preview is available as printer=Preview
.
You must use the printer ID available within Label LIVE's Print tab.
If a System Printer's name changes then the printer ID must also change.
Window
The window option controls what happens to Label LIVE during the printing process.
hide - Hide the window so it is not seen by the user
show - Show the window to the user
minimize - Show the window, but keep the window minimized
Copies
The copies option controls how many copies to print.
Controlling Printing via HTTP REST API
HTTP is a standard network protocol used by websites.
HTTP GET
Retrieve a single PNG image from your label design.
HTTP POST
Trigger a print job similar to pressing the Print button within Label LIVE. The result is a JSON payload describing success or error.
Controlling Printing via MQTT
MQTT is a lightweight pub/sub network protocol allowing for rapid lightweight integrations. Using MQTT can be faster than using the command-line URLs because it bypasses the operating system's need to re-open Label LIVE (especially true on Windows).
What's the catch? Label LIVE must be open for MQTT to be used because Label LIVE becomes the "server" (MQTT broker). Because of this, you may want to setup Label LIVE to automatically open when your computer restarts. Alternatively, you can setup a process where your integration tries MQTT first, and if that fails (the port is closed), open the URL instead. This will ensure a fallback that is slower on the first label, but subsequent labels are fast because they utilize MQTT when available.
Note: MQTT must be enabled in Label LIVE's settings. MQTT is not password protected, so please take care to not open this port (1883) to an untrusted network.
Connect to Broker
Make sure you're using MQTT protocol version 3.1.1. Version 5 is not yet supported.
Publish to Print
To start a print job simply publish a URL to the topic $LL/url
.
Subscribe to Status
To view print job status logging subscribe to the topic: $LL/status
.
Screenshot of MQTT Client
This is the MQTTX client on macOS showing a published URL and a response from the Label LIVE integration.
We Haven't Thought of Everything (yet)
You are going to think of interesting uses that aren't possible with Label LIVE. Truth is, that's an exciting opportunity for us software developers. It means we can engage you on your project to learn how we can make Label LIVE work for you and your business.
The Next Step
Don't hesitate to reach out if you have questions or need assistance integrating label printing into your business processes.