2019 SDK IPrinter.SendDataToPrinter What format is Data byte[]?

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderator: NiceLabel Support Team

Post Reply
shawnWork
Valued Contributor
Posts: 23
Joined: Tue Sep 20, 2022 11:04 pm
Location: Indianapolis

2019 SDK IPrinter.SendDataToPrinter What format is Data byte[]?

Post by shawnWork » Mon Nov 28, 2022 6:00 pm

Question: What format/encoding should be the data byte[]?
- Base64, Ascii, etc.?

Information copied below from Nice Label SDK Help File.

Printer.SendDataToPrinter Method NiceLabel SDK.NET

Sends the data to printer by creating a new print job and sending it to the spooler.

Namespace: NiceLabel.SDK
Assembly: SDK.NET.Interface (in SDK.NET.Interface.dll) Version: 17.2.0.0 (19.2.1.5400)
Syntax
--------------------------------------------------------------------------------

C#VBC++F#Copyvoid SendDataToPrinter(
byte[] data
)
Sub SendDataToPrinter (
data As Byte()
)
void SendDataToPrinter(
array<unsigned char>^ data
)
abstract SendDataToPrinter :
data : byte[] -> unit


Parameters
data
Type: System.Byte[]
The data for the print job.
See Also
--------------------------------------------------------------------------------

Reference
IPrinter Interface
NiceLabel.SDK Namespace

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 325
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: 2019 SDK IPrinter.SendDataToPrinter What format is Data byte[]?

Post by Mytch » Wed Dec 07, 2022 12:29 am

Hi,

Your "data" byte[] array should contain content that is encoded in a format which is understood by the destination printer (varies by PCL). This content contains the raw print commands which you will send to the hardware. There is no requirement from NiceLabel perspective, I would say UTF-8 is preferred over ASCII since I cannot see the benefit of the inverse.

The most common use-case is just reading an existing file to byte array then sending that directly to the printer, so it often just comes down to the format of existing content.

Simple example sending ASCII test to Zebra printer:
2022-12-06_16h30_26.png
2022-12-06_16h30_26.png (53.42 KiB) Viewed 68 times
You can see we have sent 4 bytes of data to the printer, but in practice this should contain real ZPL commands for this printer.

Mytch
www.loftware.com


Image

Post Reply