Will the ASPOSE Barcode for .Net generate Barcode from ZPL command inputs

I have a requirement in my application (.NET Application), where I need to generate barcode from ZPL commands and to save the generated bar code in the form of image or PDF file. As already mentioned in the ASPOSE site that we can save the generated bar code in the form of image with different formats mentioned on the site.
Is it possible for me to generate barcode using ZPL commands inputs using ASPOSE Barcode for .Net .
Also I need to know , Can I save the generated barcode in the form of PDF file.
kindly let me know your comments.

@prasadh

Aspose.BarCode for .NET doesn’t just create barcodes but it provides a complete framework to control almost everything about them.
For generating barcode using ZPL command inputs please provide sample code so that we could investigate it.

Moreover, Aspose.BarCode supports following Output Image Formats

  • JPEG
  • TIFF
  • PNG
  • BMP
  • GIF
  • EXIF
  • EMF
  • SVG

However, it is possible to save the generated Barcode in PDF file. For this purpose, please check the code sample given below:

// Create Barcode
BarCodeBuilder builder = new BarCodeBuilder();
builder.CodeText = "1234567";
builder.SymbologyType = Symbology.Code128;

// Creating memory stream and Saving barcode image to memory stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
builder.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);  

// Create Pdf document and Add a section to the Pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

/ Create an image object inheriting properties from the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);

// Load image data from memory stream to the image object
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.MemoryBmp;
image1.ImageInfo.OpenType = Aspose.Pdf.Generator.ImageOpenType.Memory;
image1.ImageScale = 0.5F;
System.IO.BinaryReader reader = new System.IO.BinaryReader(ms);
ms.Position = 0;
image1.ImageInfo.MemoryData = reader.ReadBytes((int)ms.Length);

// Add image to the paragraphs collection of the section and Save the Pdf
sec1.Paragraphs.Add(image1);
pdf1.Save(dataDir +"MyBarCode_out.pdf");

For more details, please follow the link given below:
https://docs.aspose.com/display/barcodenet/How+to+Integrate+Aspose.BarCode+for+.NET+with+Aspose.Pdf

HI Khan,

Thanks for your response.

Our requirement is instead of the below statement ,
builder.CodeText = “1234567”;
we will assign a ZPL command as string to the CodeText , for example ,
builder.CodeText = “^xa^BY5,2,270^FO175,550^BC^FD1234567890^FS^xz”;
This is a sample ZPL String which we have assigned to the Code Text.

Will it be possible for ASPOSE Barcode to generate barcode for the above assigned ZPL commands.
Kindly let me know your comments.

@prasadh

builder.CodeText takes text/string input, it will generate Barcode for whatever is provided as string. In your case, if you provide “^xa^BY5,2,270^FO175,550^BC^FD1234567890^FS^xz” then it will generate Barcode for this specific string without knowing that it is a ZPL command.
So best way is that run the ZPL command first and then the output of that command shall be passed to builder.CodeText as string value.

Hi Khan,

In our case we cant convert the command to string. The builder to understand that its a ZPL code and it should either generate the barcode. Or we can convert the ZPL code to Bytes of Type UTF8. Will it be possible for your builder to read and generate bar code using bytes of encoding type UTF8 type. do you have any sample code to do that. also the string below the barcode should display the proper converted text. please let me know.

@prasadh

At the moment, Aspose.BarCode is not supporting ZPL. This issue has been logged under ID “BARCODENET-36987” and we will update you as soon as ZPL support shall be available.

Moreover, Aspose.BarCode supports UTF8 Encoding. Please have a look on the Code sample given below:

string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
MemoryStream memoryStream = new MemoryStream();
// Instantiate barcode object, Set CodeText, Barcode Symbology and Text Encoding
using (BarCodeBuilder barCodeBuilder = new BarCodeBuilder())
{
     BarCodeBuilder builder = new BarCodeBuilder("Слово", EncodeTypes.QR);
     barCodeBuilder.CodeTextEncoding = Encoding.UTF8;
     barCodeBuilder.Save(dataDir + "" + memoryStream + "_out.png", 
     BarCodeImageFormat.Png);
}

string fileName = dataDir + "" + memoryStream + "_out.png";
using (BarCodeReader reader = new BarCodeReader(fileName, DecodeType.QR))
{
     reader.SetDetectEncoding(false);
     if (reader.Read())
        Console.WriteLine(reader.GetCodeText(Encoding.UTF8)); //"Слово"
}

Hi Khan,
From our previous discussion , I came to know that ZPL commands are not supported as input as of now.
I have a query related to my label design. will it be possible for us to design a label with barcode and with few text using ASPOSE Barcode. I have attached the same barcode label along with this topic. My requirement is I need to design a barcode label as attached and I need to save it as image or PDF. Also I need to print the barcode. kindly let me know your comments. if yes please provide me some samples.

BarCode label.png (5.6 KB)

Thanks,
Prasadh. N.S

@prasadh

For generating Barcode with label, the font, size, color and location properties can be set using Aspose.BarCode. Please have a look on the Code Sample given below:

            string dst = dataDir + "codetext-appearence_out.jpg";

            // Set the symbology type to Code128
            BarCodeBuilder barCodeBuilder = new BarCodeBuilder("12345678", EncodeTypes.Code128)
            {
                // Set differnt barcode properties
                CodeTextAlignment = StringAlignment.Center,
                CodeLocation = CodeLocation.Below,
                CodeTextColor = Color.Black,
                CodeTextSpace = 1.0f,
                CodeTextFont = new Font("Arial", 14)
            };          
            barCodeBuilder.Save(dst, ImageFormat.Jpeg);

And for saving Barcode in image or PDF, please follow the code sample provided in previous reply. (https://forum.aspose.com/t/will-the-aspose-barcode-for-net-generate-barcode-from-zpl-command-inputs/182641/2)

For printing the Barcode, Please follow the instructions given in this article.
https://docs.aspose.com/display/barcodenet/How+to+Print+Barcodes+in+.NET+Windows+Forms

ZPL from SVG can be created with this tool: