Getting Started
EPLPrinter Emulator SDK works like a Virtual EPL Printer device. You setup the virtual printer with basic settings like the DPI resolution and default Label Size to finally pass to it the EPL commands to be processed.
First sample code - Convert EPL to PDF
This first sample code creates an instance of EPLPrinter class, then set the virtual printer properties and pass to it the EPL commands to be processed. Finally, the output rendering is saved to a PDF file on disk.
C# - First sample code - Convert EPL to PDF
using Neodynamic.SDK.EPLPrinter;
//...
try
{
//The EPL commands to be rendered...
string EPLCommands = @"\nN\nq609\nQ203,26\nB26,26,0,UA0,2,2,152,B,\"603679025109\"\nA253,26,0,3,1,1,N,\"SKU 6205518 MFG 6354\"\nA253,56,0,3,1,1,N,\"2XIST TROPICAL BEACH\"\nA253,86,0,3,1,1,N,\"STRIPE SQUARE CUT TRUNK\"\nA253,116,0,3,1,1,N,\"BRICK\"\nA253,146,0,3,1,1,N,\"X-LARGE\"\nP1,1\n";
//Create an instance of EPLPrinter class
using (var myEPLPrinter = new EPLPrinter("LICENSE OWNER", "LICENSE KEY"))
{
//Set printer DPI
//The DPI value to be set must match the value for which
//the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203;
//Apply antialiasing?
myEPLPrinter.AntiAlias = true;
//set label size e.g. 4in x 6in
myEPLPrinter.LabelWidth = 4 * myEPLPrinter.Dpi;
myEPLPrinter.LabelHeight = 6 * myEPLPrinter.Dpi;
//Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.PDF;
//Set EPL commands to be processed...
var buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc);
// the buffer variable contains the binary output of the EPL rendering result
// The format of this buffer depends on the RenderOutputFormat property setting
if (buffer != null && buffer.Count > 0)
{
//Save output rendering to PDF
System.IO.File.WriteAllBytes(@"c:\temp\sample-EPL-label.pdf", buffer[0]);
}
}
}
catch (Exception ex)
{
throw ex;
}
VB - First sample code - Convert EPL to PDF
Imports Neodynamic.SDK.EPLPrinter
'...
Try
'The EPL commands to be rendered...
Dim EPLCommands As String = Chr(10) & "N" & Chr(10) & "q609" & Chr(10) & "Q203,26" & Chr(10) & "B26,26,0,UA0,2,2,152,B,""603679025109""" & Chr(10) & "A253,26,0,3,1,1,N,""SKU 6205518 MFG 6354""" & Chr(10) & "A253,56,0,3,1,1,N,""2XIST TROPICAL BEACH""" & Chr(10) & "A253,86,0,3,1,1,N,""STRIPE SQUARE CUT TRUNK""" & Chr(10) & "A253,116,0,3,1,1,N,""BRICK""" & Chr(10) & "A253,146,0,3,1,1,N,""X-LARGE""" & Chr(10) & "P1,1" & Chr(10)
'Create an instance of EPLPrinter class
Using myEPLPrinter = New EPLPrinter("LICENSE OWNER", "LICENSE KEY")
'Set printer DPI
'The DPI value to be set must match the value for which
'the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203
'Apply antialiasing?
myEPLPrinter.AntiAlias = true
'set label size e.g. 4in x 6in
myEPLPrinter.LabelWidth = (4 * myEPLPrinter.Dpi)
myEPLPrinter.LabelHeight = (6 * myEPLPrinter.Dpi)
'Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.PDF
'Set EPL commands to be processed...
Dim buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc)
' the buffer variable contains the binary output of the EPL rendering result
' The format of this buffer depends on the RenderOutputFormat property setting
If ((Not (buffer) Is Nothing) _
AndAlso (buffer.Count > 0)) Then
'Save output rendering to PDF
System.IO.File.WriteAllBytes("c:\temp\sample-EPL-label.pdf", buffer(0))
End If
End Using
Catch ex As Exception
Throw ex
End Try
Sample code - Convert EPL to PNG
This sample code creates an instance of EPLPrinter class, then set the virtual printer properties and pass to it the EPL commands to be processed. Finally, the output rendering is saved to a PNG file on disk.
C# - Sample code - Convert EPL to PNG
using Neodynamic.SDK.EPLPrinter;
//...
try
{
//The EPL commands to be rendered...
string EPLCommands = @"\nN\nq609\nQ203,26\nB26,26,0,UA0,2,2,152,B,\"603679025109\"\nA253,26,0,3,1,1,N,\"SKU 6205518 MFG 6354\"\nA253,56,0,3,1,1,N,\"2XIST TROPICAL BEACH\"\nA253,86,0,3,1,1,N,\"STRIPE SQUARE CUT TRUNK\"\nA253,116,0,3,1,1,N,\"BRICK\"\nA253,146,0,3,1,1,N,\"X-LARGE\"\nP1,1\n";
//Create an instance of EPLPrinter class
using (var myEPLPrinter = new EPLPrinter("LICENSE OWNER", "LICENSE KEY"))
{
//Set printer DPI
//The DPI value to be set must match the value for which
//the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203;
//Apply antialiasing?
myEPLPrinter.AntiAlias = true;
//set label size e.g. 4in x 6in
myEPLPrinter.LabelWidth = 4 * myEPLPrinter.Dpi;
myEPLPrinter.LabelHeight = 6 * myEPLPrinter.Dpi;
//Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.PNG;
//Set EPL commands to be processed...
var buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc);
// the buffer variable contains the binary output of the EPL rendering result
// The format of this buffer depends on the RenderOutputFormat property setting
if (buffer != null && buffer.Count > 0)
{
//Save output rendering to PDF
System.IO.File.WriteAllBytes(@"c:\temp\sample-EPL-label.png", buffer[0]);
}
}
}
catch (Exception ex)
{
throw ex;
}
VB - Sample code - Convert EPL to PNG
Imports Neodynamic.SDK.EPLPrinter
'...
Try
'The EPL commands to be rendered...
Dim EPLCommands As String = Chr(10) & "N" & Chr(10) & "q609" & Chr(10) & "Q203,26" & Chr(10) & "B26,26,0,UA0,2,2,152,B,""603679025109""" & Chr(10) & "A253,26,0,3,1,1,N,""SKU 6205518 MFG 6354""" & Chr(10) & "A253,56,0,3,1,1,N,""2XIST TROPICAL BEACH""" & Chr(10) & "A253,86,0,3,1,1,N,""STRIPE SQUARE CUT TRUNK""" & Chr(10) & "A253,116,0,3,1,1,N,""BRICK""" & Chr(10) & "A253,146,0,3,1,1,N,""X-LARGE""" & Chr(10) & "P1,1" & Chr(10)
'Create an instance of EPLPrinter class
Using myEPLPrinter = New EPLPrinter("LICENSE OWNER", "LICENSE KEY")
'Set printer DPI
'The DPI value to be set must match the value for which
'the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203
'Apply antialiasing?
myEPLPrinter.AntiAlias = true
'set label size e.g. 4in x 6in
myEPLPrinter.LabelWidth = (4 * myEPLPrinter.Dpi)
myEPLPrinter.LabelHeight = (6 * myEPLPrinter.Dpi)
'Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.PNG
'Set EPL commands to be processed...
Dim buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc)
' the buffer variable contains the binary output of the EPL rendering result
' The format of this buffer depends on the RenderOutputFormat property setting
If ((Not (buffer) Is Nothing) _
AndAlso (buffer.Count > 0)) Then
'Save output rendering to PDF
System.IO.File.WriteAllBytes("c:\temp\sample-EPL-label.png", buffer(0))
End If
End Using
Catch ex As Exception
Throw ex
End Try
Handling multiple labels generation
Depending on the commands you specify for being processed, they could make the EPLPrinter Emulator SDK to generate more than one output rendering.
For PDF output format, the output rendering will be a single PDF buffer containing as many pages as labels that were generated.
For PNG, JPG, PCX, GRF, EPL, FP & NV output formats, the output rendering will be a list of byte arrays, one array per labels that were generated.
The following sample code shows how to save them for the image formats e.g. for JPG. The specified commands will generate 3 label images.
C# - Handling multiple labels generation
using Neodynamic.SDK.EPLPrinter;
//...
try
{
//The EPL commands to be rendered...
string EPLCommands = @"\nN\nq609\nQ203,26\nB26,26,0,UA0,2,2,152,B,\"603679025109\"\nA253,26,0,3,1,1,N,\"SKU 6205518 MFG 6354\"\nA253,56,0,3,1,1,N,\"2XIST TROPICAL BEACH\"\nA253,86,0,3,1,1,N,\"STRIPE SQUARE CUT TRUNK\"\nA253,116,0,3,1,1,N,\"BRICK\"\nA253,146,0,3,1,1,N,\"X-LARGE\"\nP3\n";
//Create an instance of EPLPrinter class
using (var myEPLPrinter = new EPLPrinter("LICENSE OWNER", "LICENSE KEY"))
{
//Set printer DPI
//The DPI value to be set must match the value for which
//the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203;
//Apply antialiasing?
myEPLPrinter.AntiAlias = true;
//set label size e.g. 4in x 2in
myEPLPrinter.LabelWidth = 4 * myEPLPrinter.Dpi;
myEPLPrinter.LabelHeight = 2 * myEPLPrinter.Dpi;
//Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.JPG;
//Set EPL commands to be processed...
var buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc);
// the buffer variable contains the binary output of the EPL rendering result
// The format of this buffer depends on the RenderOutputFormat property setting
if (buffer != null && buffer.Count > 0)
{
//save images on disk
for(int i = 0; i < buffer.Count; i++)
{
System.IO.File.WriteAllBytes(@"c:\temp\sample-EPL-label-" + i.ToString().PadLeft(buffer.Count, '0') + ".jpg", buffer[i]);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
VB - Handling multiple labels generation
Imports Neodynamic.SDK.EPLPrinter
'...
Try
'The EPL commands to be rendered...
Dim EPLCommands As String = Chr(10) & "N" & Chr(10) & "q609" & Chr(10) & "Q203,26" & Chr(10) & "B26,26,0,UA0,2,2,152,B,""603679025109""" & Chr(10) & "A253,26,0,3,1,1,N,""SKU 6205518 MFG 6354""" & Chr(10) & "A253,56,0,3,1,1,N,""2XIST TROPICAL BEACH""" & Chr(10) & "A253,86,0,3,1,1,N,""STRIPE SQUARE CUT TRUNK""" & Chr(10) & "A253,116,0,3,1,1,N,""BRICK""" & Chr(10) & "A253,146,0,3,1,1,N,""X-LARGE""" & Chr(10) & "P3" & Chr(10)
'Create an instance of EPLPrinter class
Using myEPLPrinter = New EPLPrinter("LICENSE OWNER", "LICENSE KEY")
'Set printer DPI
'The DPI value to be set must match the value for which
'the EPL commands to be processed were created!!!
myEPLPrinter.Dpi = 203
'Apply antialiasing?
myEPLPrinter.AntiAlias = true
'set label size e.g. 4in x 2in
myEPLPrinter.LabelWidth = (4 * myEPLPrinter.Dpi)
myEPLPrinter.LabelHeight = (2 * myEPLPrinter.Dpi)
'Set image or doc format for output rendering
myEPLPrinter.RenderOutputFormat = RenderOutputFormat.JPG
'Set EPL commands to be processed...
Dim buffer = myEPLPrinter.ProcessCommands(EPLCommands, enc)
' the buffer variable contains the binary output of the EPL rendering result
' The format of this buffer depends on the RenderOutputFormat property setting
If ((Not (buffer) Is Nothing) _
AndAlso (buffer.Count > 0)) Then
'save images on disk
Dim i As Integer = 0
Do While (i < buffer.Count)
System.IO.File.WriteAllBytes(("c:\temp\sample-EPL-label-" _
+ (i.ToString.PadLeft(buffer.Count, ChrW(48)) + ".jpg")), buffer(i))
i = (i + 1)
Loop
End If
End Using
Catch ex As Exception
Throw ex
End Try
Advanced Samples for Web & Desktop Projects
EPLPrinter Emulator SDK installer package will install a set of sample projects for ASP.NET Web as well as for Desktop apps including morfe advanced settings and usage. The same projects are also available in the following repo https://github.com/neodynamic/EPL-Printer-Emulator-SDK
Need Assistance?
- For tech assistance please contact our Support Team