I'm trying to implement print barcode label for my MVC application and in order to do it I installed the nuget package "Neodynamic.WebControls.BarcodeProfessional" , after I installed the package I implemented this C# code:
//Create a Barcode Professional object Neodynamic.WebControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WebControls.BarcodeProfessional.BarcodeProfessional(); //Set the barcode symbology to Code 128 bcp.Symbology = Neodynamic.WebControls.BarcodeProfessional.Symbology.Code128; //Set the value to encode bcp.Code = "1234567890"; bcp.CodeFormatPattern = DateTime.Today.ToString(); //Barcode dimensions settings bcp.BarHeight = 1.0f; bcp.BarWidth = 0.01f; //Resolution float dpi = 300.0f; //Target size in inches System.Drawing.SizeF targetArea = new System.Drawing.SizeF(1.0f, 0.5f); //Get the barcode image fitting the target area System.Drawing.Image imgBarcode = bcp.GetBarcodeImage(dpi, targetArea); //Save it on disk in PNG format imgBarcode.Save(@"D:\temp\barcode128.png", System.Drawing.Imaging.ImageFormat.Png); imgBarcode.Dispose();
My question:
How can I Print the barcode directly to the printer instead of saving to png file and then print? I'm wondering if there is a way to do it.
I was trying to do it, but there is no print function in this DLL reference.
Note:
I would like to know if there is better way to print barcode labels.
thanks ,
ASP.NETC#
Last Comment
Moti Mashiah
8/22/2022 - Mon
Ioannis Paraskevopoulos
Hi,
One way i had done it in the past was by embeding the image data in the html.
One way i had done it in the past was by embeding the image data in the html.
The base idea was to achieve the following:
Open in new window
You only need to get the base64 string of the image you have created.
You may get an idea of how to convert the Image to Base64 here.
Giannis