Hi i am developing a web based billing solution where in i need to print a bar code or receipt on a local printer. i am using ASP.NET and MVC5
Please suggest
Rgds
Bhaskaran
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amin DodinPosted Jan 5, 2017, 7:25 PM
You can use a barcode library such as LEADTOOLS to write (draw) the barcodes on an image at the server side using .NET code. (Disclaimer: I’m an employee of this library's vendor).
The following code writes a barcode on an image and saves it into a MemoryStream:
//Create white image
RasterImage bitmapImage = RasterImage.Create(400, 150, 24, 300, RasterColor.White);
//Write the barcode on the image
Leadtools.Barcode.BarcodeEngine engine = new BarcodeEngine();
BarcodeWriteOptions writeOptions = engine.Writer.GetDefaultOptions(BarcodeSymbology.Code3Of9);
string sampleData = "123-45678";
//There are many supported types, not just Code 3 of 9
engine.Writer.WriteBarcode(bitmapImage, new BarcodeData(BarcodeSymbology.Code3Of9, sampleData), writeOptions);
//Save the image to a stream
RasterCodecs codecs = new RasterCodecs();
codecs.Save(bitmapImage, memoryStream, RasterImageFormat.Png, 24);
You can then return the resulting image as part of your response page (receipt) and invoke printing of the page using JavaScript. There's a free evaluation edition on www.leadtools.com with free technical support.Suthish NairPosted Jan 5, 2017, 4:26 AM