Martyn Bell
Martyn Bell

Reputation: 97

Datamax DLP Send and print an image above other text using python

Does anyone have any experience with the DLP Language?

Im trying to use python to send some text and barcodes and now i need to send a bmp image to.

The documentation is really hard for me to read so i was hoping others have used before and can help me.

Here is the documentation https://www.honeywellaidc.com/en/-/media/en/files-public/technical-publications/printers/1common/dpl_88-2360-01_b.pdf

Upvotes: 1

Views: 1274

Answers (1)

UncleSaam
UncleSaam

Reputation: 356

It is absolutely possible. Here is how I am doing it at the moment, on a Datamax O'Neil printer installed on Windows. The DPL command below can be sent to the printer using the win32print wrapper for python, or sent directly to the printer's IP using the socket library:

DPL code:

dpl_code = b'''<STX>LH15D11FA+
191100200140035THIS IS SOME TEXT
1W1j00050010000THIS IS A CODE128 BARCODE
121100000850010
1Y1100501600315THIS_IS_AN_IMAGE_FILE_ALREADY_STORED_ON_THE_PRINTER
191100202650010THIS IS SOME MORE TEXT
E'''

The < STX > must be replaced by a special character (value: 0x02 by default, which doesn't render as text). Each line represents either a string of text, or a graphical component like a barcode or image pre-stored in the printer's memory. for more details on the language syntax, refer to the DPL command reference.

For a printer installed as the default printer on Windows:

import win32print

printer_name = win32print.GetDefaultPrinter()
printer = win32print.OpenPrinter(printer_name)
win32print.StartDocPrinter(printer, 1, ("raw_data", None, "RAW"))
win32print.WritePrinter(printer, dpl_code)
win32print.EndDocPrinter(printer)
win32print.ClosePrinter(printer)

For a printer accessible via network:

import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as connection:
  connection.settimeout(timeout)
  connection.connect((ip_address, port))
  connection.send(dpl_code)
  response = connection.recv(1024)

This method is somewhat successful for me, but I found it much easier to work with Zebra printers (ZPL). As for sending images and printing them, I have not yet been successful unfortunately. I need to first pre-store an image in the printer's memory (as a BMP file) using the NetiraCT software and refer to it with the DPL code.

Upvotes: 1

Related Questions