This project is built on top of the BinaryKits.Zpl library.
ZPL2PDF is a project for converting labels in ZPL format into a PDF file. The program processes the labels, renders images in memory and compiles these images into a PDF, where each page contains a label.
-
Label Processing: Uses the
LabelFileReader
class to read the file and separate the labels based on the^XA
and^XZ
delimiters. -
In-Memory Rendering: The
LabelRenderer
class analyzes the ZPL content and renders the labels into images, keeping the data in memory without the need for temporary storage. -
PDF Generation: The
PdfGenerator
class generates a PDF where each image is added to a page. The PDF file is saved in the user's specified output folder, using the specified output file name or a default name based on the current date and time.
-
Receiving Parameters:
TheMain
method analyzes the arguments received:- The
-i
parameter specifies the input file path. - The
-z
parameter specifies the ZPL content directly. - The
-o
parameter specifies the output folder path. - The
-n
parameter specifies the output file name (optional).
- The
-
Content reading
The file is read usingLabelFileReader.ReadFile(inputFile)
or the ZPL content is used directly. -
Label separation:
TheLabelFileReader.SplitLabels(fileContent)
method splits the content into individual labels, based on the^XA
and^XZ
delimiters. -
Image rendering
TheLabelRenderer
class processes each label and renders images (in byte[]) with the defined dimensions and density. -
PDF generation:
The PDF is generated using thePdfGenerator.GeneratePdf(imageDataList, outputPdf)
class, whereoutputPdf
is built in the specified output folder with the specified output file name or a default name.
-
Specifying the Input and Output:
-
Reads the specified file and saves it in the specified output folder.
ZPL2PDF.exe -i "C:\Path\to\input.txt" -o "C:\Path\to\output"
-
-
Specifying the ZPL Content Directly:
-
Uses the specified ZPL content and saves it in the specified output folder.
ZPL2PDF.exe -z "^XA^FO50,50^ADN,36,20^FDHello, World!^FS^XZ" -o "C:\Path\to\output"
-
-
Specifying the Output File Name:
-
Reads the specified file, saves it in the specified output folder with the specified output file name.
ZPL2PDF.exe -i "C:\Path\to\input.txt" -o "C:\Path\to\output" -n "output_filename.pdf"
-
The program can be compiled into an executable (ZPL2PDF.exe) and called from another application, such as an ERP, using functions to start processes (e.g., Process.Start in C#) and passing the necessary parameters.
- BinaryKits.Zpl: For analyzing and rendering ZPL labels.
- PdfSharpCore: For creating and manipulating the PDF file.
ZPL2PDF was developed with a focus on modularization (separate classes for reading, rendering, and generating the PDF) and flexibility, allowing different input options and easy integration with other systems.