Printer Status
This action communicates with the printer to acquire its real-time state, and contacts the Windows Spooler for additional information about the printer and its jobs.
As a result, the information about errors, spooler status, number of jobs in the spooler is collected. This uncovers potential errors and makes them easy to identify.
Possible use case scenarios. (1) Verifying the printer status before printing. If the printer is in error state, you print the label to a backup printer. (2) Counting the number of jobs waiting in a spooler of main printer. If there are too many, you will print label to alternative printer. (3) You will verify the printer status before printing. If the printer is in error state, you will not print labels, but report the error back to the main system using any of the outbound actions, such as Send Data to TCP/IP Port, HTTP Request, Execute SQL Statement, Web Service, or as the trigger response.
Live Printer Status Prerequisites
To make live printer status monitoring possible, follow these instructions:
- Use the Loftware Printer Driver to receive detailed status information. If using any other printer driver, you can only monitor the parameters retrieved from the Windows Spooler.
- The printer must be capable of reporting its live status. For the printer models supporting bidirectional communication see Loftware drivers.
- Printer must be connected to an interface with support for bidirectional communication.
- Bidirectional support must be enabled in Control Panel > Hardware and Sound > Devices and Printers > driver > Printer Properties > Ports tab > Enable bidirectional support.
- If using a network-connected label printer, make sure you are using Advanced TCP/IP Port, not Standard TCP/IP Port.
About group identifies the selected action.
- Name: allows you to define a custom action name. This makes actions easily recognizable on the solution's list of actions. By default, the action name is taken from its type.
- Description: custom information about the action. Enter a description to explain the purpose and role of action in a solution.
- Action type: read-only information about the selected action type.
Printer group selects the printer.
-
Printer name: specifies the printer name to be used for the current print job.
You can select a printer from the list of locally installed printer drivers, or you can enter any printer name. Data source enables variable printer name. When enabled, select or create a variable that contains the printer name when a trigger is executed or an event takes place. Usually, the variable value is assigned by a filter.
Data Mapping group sets the parameters that are returned as a result of the Printer Status action.
Warning
Most of the following parameters are only supported with Loftware printer driver. If you are using any other printer driver, you can use only the spooler-related parameters.
-
Printer status: specifies the printer live status formatted as a string.
If the printer reports multiple states, all states are merged into a single string, delimited by comma ",". If there are no reported printer issues, this field is empty. Printer status might be set to Offline, Out of labels or Ribbon near end. Since there is no standardized reporting protocol, each printer vendor uses proprietary status messages.
-
Printer error: boolean (true/false) value of the printer error status.
-
Printer offline: boolean (true/false) value of the printer offline status.
-
Driver paused: boolean (true/false) value of the driver pause status.
-
Loftware driver: specifies boolean (true/false) value of the printer driver status. Provides information if the selected driver is a Loftware driver.
-
Spooler status: specifies the spooler status in a string form – as reported by the Windows system. The spooler can simultaneously report several statuses. In this case, the statuses are merged using comma ",".
-
Spooler status ID: specifies spooler status formatted as a number – as reported by the Windows system. The spooler can simultaneously report several statuses. In this case, the returned status IDs contains all IDs as flags. For example, value 5 represents status IDs 4 and 1, which translates to "Printer is in error, Printer is paused". Refer to the table below.
Tip
The action returns a decimal value, the values in the table below are in hex format, so you will have to do the conversion before parsing the response.
-
Table of spooler status IDs and matching descriptions
Spooler status ID (in hex)
Spooler status description
0
No status.
1
Printer is paused.
2
Printer is printing.
4
Printer is in error.
8
Printer is not available.
10
Printer is out of paper.
20
Manual feed required.
40
Printer has a problem with paper.
80
Printer is offline.
100
Active Input/Output state.
200
Printer is busy.
400
Paper jam.
800
Output bin is full.
2000
Printer is waiting.
4000
Printer is processing.
10000
Printer is warming up.
20000
Toner/Ink level is low.
40000
No toner left in the printer.
80000
Current page can not be printed.
100000
User intervention is required.
200000
Printer is out of memory.
400000
Door is open.
800000
Unknown error.
1000000
Printer is in power save mode.
-
Number of jobs in the spooler: specifies the number of jobs that are in the spooler for the selected printer.
-
Loftware driver extended printer status: returns printer status and errors data in JSON format. Data includes also printer parameters like firmware version, printhead distance, and ink level.
Note
You need the latest Loftware driver to get the Loftware driver extended printer status.
Example
Loftware Automation returns the following JSON content:
{ "printerName":"Production_printer_09", "version":"1", "responseType":"status3", "overallStatus":"error", "operationState":"pause", "printerType":"Thermal Transfer Label Printer", "deviceStatus": [ { "item": "fatalError", "type": "string", "internalId":"ERR_PAPER_OUT", "shortString":"Paper Out", "longString":"Printer is out of paper." }, { "item": "error", "type": "string", "internalId": "ERR_RIBBON_OUT", "shortString": "Ribbon Out", "longString": "Printer is out of Ribbon." } ], "deviceParameters": [ { "item":"state", "type":"float", "internalId":"INFO_PRINTHEAD_DISTANCE", "unit": "meter", "value": 789, "shortDescription":"Printhead distance", "longDescription":"Distance of printhead usage." }, { "item": "state", "type": "string", "internalId": "INFO_FW", "unit": "", "value": "FW27.3.13", "shortDescription": "Firmware version", "longDescription": "The version of the Firmware loaded on the printer." }, { "item": "property", "type": "integer", "internalId": "INFO_PRINT_DISTANCE", "unit": "seconds", "value": 16004, "shortDescription": "Print Distance", "longDescription": "Print Distance that the printer printed since odometer reset." } ] }
Action Execution and Error Handling
Each action can be set as a conditional action. Conditional actions only run when the defined conditions allow them to be run. To define these conditions, click Show execution and error handling options.
Execution options are:
- Enabled: specifies if the action is enabled or disabled. Only enabled actions will execute. This functionality may be used while testing a form.
- Condition: defines one-line programming expression that must provide a Boolean value (true or false). When the result of the expression is true, the action will execute. Condition offers a way to avoid executing actions every time.
Error handling options are:
- Ignore failure: specifies whether an error should be ignored. If enabled, the execution of actions continues even if the current action fails.
Note
Nested actions that depend on the current action do not execute in case of a failure. The execution of actions continues with the next action on the same level as the current action. The error is logged but does not break the execution of the action.
- Save error to variable: allows you to select or create a variable to save the error to. The same cause of the error is also saved to internal variables ActionLastErrorId and ActionLastErrorDesc.
At the end of printing, you might want to send the status update to an external application using the HTTP Request action. If the printing action fails, action processing stops. In order to execute the reporting even after the failed print action, the Print Label action must have the option Ignore failure enabled.