How to generate barcode from a string using C#?

2019-01-21 14:46发布

  • Is it possible to generate barcode from a string using c#?
  • Is there any builtin classes for generating barcodes in asp.net?
  • Is it possible to detect a barcode printer connected with a system?

6条回答
We Are One
3楼-- · 2019-01-21 15:19

Is it possible to generate barcodes from a string using c#?

Yes, it is. There are quite a lot of frameworks that do it - either as a font or an image.

Is there any built-in classes for generating barcodes in asp.net?

No, but this c# project on github allows a string to be converted into an image (even multiple barcode types). All you need to do then is display the image in your application, just like any other image.

Is it possible to detect a barcode printer connected with a system?

Yes, in a WinForm application, for example, you could use System.Drawing.Printing.PrinterSettings.InstalledPrinters.

查看更多
闹够了就滚
4楼-- · 2019-01-21 15:29

Barcode fonts exist in asp.net (IE web). You could draw barcode text to an image and display that. This could be a similar implementation to a capcha control.

查看更多
冷血范
5楼-- · 2019-01-21 15:32

Yep. Of course it is possible. :-)
As far as I know there are two ways to generate bar codes:

  1. Using a special bar code font (try to google for "barcode font free")
  2. Render the bar code to an image and display that (try using the Barcode Rendering Framework available on codeplex)

In response to your updated question about detecting barcode printers:
I think a barcode printer will show up as a regular printer on your system. At least that is how the devices I have played with have worked.
This means that you can detect a specific barcode printer by enumerating the installed printers on the system and looking for the specified device, but in most cases I would suggest that you let the user specify the printer himself using either the standard print dialog or using a custom dialog.

查看更多
Explosion°爆炸
6楼-- · 2019-01-21 15:38

to detect if you have printer installed then you may simply enumerate available printers using:

 System.Drawing.Printing.PrinterSettings.InstalledPrinters
查看更多
劳资没心,怎么记你
7楼-- · 2019-01-21 15:42

For generating barcodes try http://www.codeproject.com/Articles/20823/Barcode-Image-Generation-Library

Allows saving to image with or without label and supports a number of formats.

查看更多
登录 后发表回答