To include the NiceLabel Print Engine in your application, you need to create a reference to the SDK.NET.Interface.dll
assembly. The file is typically located in the c:\Program Files\NiceLabel\NiceLabel 10\\bin.net\
folder.
We recommend you keep the files of NiceLabel .NET API in a separate folder from your application’s executable file. After you make the reference to the SDK.NET.Interface.dll
, you can copy the .dll file to your application’s bin folder.
NiceLabel .NET API components have no label design capabilities and no user interface. NiceLabel .NET API is a print engine that is embedded into other applications.
Label templates, which the NiceLabel Print Engine uses for printing, must be created in NiceLabel Desktop Designer. It is the label design tool to create the graphical layout of label templates, define object properties, and variable fields.
Use NiceLabel Desktop Designer to create your label templates, and use NiceLabel .NET API to merge user data, and manage label printing.
All NiceLabel .NET API features are exposed through the NiceLabel.SDK.IPrintEngine
interface.
When your application refers to the SDK.NET.Interface.dll
assembly, the application can access PrintEngineFactory
static class. Before using any other properties, the application needs to set the SDKFilesPath
property. This is necessary for the library to access the NiceLabel .NET API files, which can exist in different locations.
Once the location is known, the application can retrieve the IPrintEngine
interface by accessing the PrintEngineFactory.PrintEngine
property.
After retrieving the PrintEngine
, a call to Initialize()
method of the returned IPrintEngine
instance needs to be done.
IPrintEngine printEngine = PrintEngineFactory.PrintEngine; printEngine.Initialize();
Before terminating the application, the Shutdown()
method of the IPrintEngine
instance should be called to release all resources used by the library.
The OpenLabel()
method allows your application to manage which templates your users can access. Templates can be opened from your clients’ file systems or from System.IO.Stream
objects for users who want to deploy them embedded in their application or maintained in a database.
Control Center users can manage label files in Documents storage.
NiceLabel Print Engine provides a list of locally available printer drivers to your applications and reduces the need for coding.
Printer selection follows the hierarchy:
-
The
PrinterName
property. -
The printer name stored in your label template.
-
The system’s default printer.
Note
NiceLabel .NET API-based applications use the same print engine for previews and printing, so the graphical previews of your labels are identical to printed labels.
With the GetLabelPreview()
method, your application can retrieve a graphical preview of the next label that will be printed.
The PrintToGraphics()
method generates a series of images of all the labels that would be printed. This way you can work with proofs-of-concept.
NiceLabel technology allows you to print to any printer with a Windows driver. NiceLabel output also provides printer commands for more than 4000 different printer models allowing you to use native printer features, such as internal barcodes, fonts, and counters.
NiceLabel .NET API offers three different printing modes:
-
Synchronous Printing. This mode maintains a connection to the print process. With this mode, the application sends data to the print process and keeps the connection established as long as the print process is busy. Calling the
Print()
method returns feedback about the print job. -
Asynchronous Printing. This mode processes the print job in its own thread. This boosts performance and increases the number of print jobs that can be processed in a time frame. When using the
PrintAsync()
method, the caller is notified via event handlers when print process status changes. -
Session Printing. Youse this option when you don't want to interrupt your print jobs or you need to print different labels on a single page, NiceLabel enables this with session print.
All labels within a single session print are sent to the printer as a single job, ensuring the correct printing order.
Each session printing includes three stages:
-
StartSessionPrint()
initializes a new printing session. -
SessionPrint()
adds a print request to the current session and can be called multiple times. -
EndSessionPrint()
finalizes the current session.
-
NiceLabel .NET API lets you monitor the printing process through print job status updates regardless of the label printing mode you chose. This detailed access to your printing process allows you to control and respond correctly to any situation.
All exceptions from the NiceLabel Print Engine are SDKException
type. This class contains detailed information about errors that might occur.