asp.net mvc - print bardcode

Hi Guys,

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();

Open in new window


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 ,
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ioannis ParaskevopoulosCommented:
Hi,

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:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

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
Moti Mashiah.NET DeveloperAuthor Commented:
Hi,

Thanks for your respond and it was very helpful, but now I change a bit the logic as I would like to popup the image after I save and then print.

I was trying to go with bitmap and I didn't know how to complete the code in order to open the file after I saved.

 imgBarcode.Save(@"D:\temp\barcode128.png", System.Drawing.Imaging.ImageFormat.Png);
            imgBarcode.Dispose();
            Bitmap image1 = (Bitmap)Image.FromFile(@"D:\temp\barcode128.png", true);

Open in new window

Ioannis ParaskevopoulosCommented:
How are you going to popup? Are you using a js library? You could always use a url to your saved image in an img tag.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Moti Mashiah.NET DeveloperAuthor Commented:
Thx
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.