在 vb.net 中生成 Code 128 条码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12844687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Code 128 Barcode generation in vb.net
提问by Brandon
I am attempting to take a string and convert it into a code 128 barcode in vb.net. I am a novice programmer and was wondering what some people thought would be the best design practices for accomplishing this.
我试图在 vb.net 中获取一个字符串并将其转换为代码 128 条码。我是一名新手程序员,想知道有些人认为实现这一目标的最佳设计实践是什么。
A simple google search has yielded a few seemingly free solutions to this. http://www.onbarcode.com/vb_net/code-128-generator.htmlfor example
一个简单的谷歌搜索已经产生了一些看似免费的解决方案。 http://www.onbarcode.com/vb_net/code-128-generator.html例如
I could also attempt to do this myself, but I'm not sure the exact method of converting strings into barcodes. I am going to keep looking into this but if someone knew this off the top of their head already it could save me some time.
我也可以尝试自己这样做,但我不确定将字符串转换为条形码的确切方法。我会继续研究这个,但如果有人已经知道这一点,它可以节省我一些时间。
Thanks in advance
提前致谢
采纳答案by fakeChina
If you don't want to write any code for string conversion in barcode and don't want to buy an external component, you can use the ItextSharp library ( http://sourceforge.net/projects/itextsharp/) which is in my opinion the simplest way to achieve your goal. You can find several resources online and on stackoverflow too for itextsharp, mostly in c# but also vb.net.
如果您不想为条码中的字符串转换编写任何代码并且不想购买外部组件,您可以使用我的 ItextSharp 库(http://sourceforge.net/projects/itextsharp/)意见是实现目标的最简单方法。您也可以在网上和 stackoverflow 上找到 itextsharp 的一些资源,主要是在 c# 中,也可以在 vb.net 中。
for barcode generation vb.net code you can have a look here: http://professionalaspnet.com/archive/2008/11/09/A-Quick-and-Dirty-Bar-Code-Image-httpHandler.aspx
对于条形码生成 vb.net 代码,您可以在这里查看:http: //professionalaspnet.com/archive/2008/11/09/A-Quick-and-Dirty-Bar-Code-Image-httpHandler.aspx
回答by Matt Wilko
Have a look at the following codeproject page - Barcode Image Generation Library
看看下面的代码项目页面 -条码图像生成库
This allows you to generate a barcode image in your desired format from a string.
这允许您从字符串生成所需格式的条形码图像。
It should be enough to get you started
这应该足以让你开始
回答by Yvette
The following examples are taken from
以下例子摘自
http://www.onbarcode.com/tutorial/vb-net-barcode-generation.html
http://www.onbarcode.com/tutorial/vb-net-barcode-generation.html
Generate barcode
生成条码
Dim barcode As OnBarcode.Barcode.Linear
' Create linear barcode object
barcode = New OnBarcode.Barcode.Linear()
' Set barcode symbology type to Code-39
barcode.Type = OnBarcode.Barcode.BarcodeType.CODE39
' Set barcode data to encode
barcode.Data = "0123456789"
' Set barcode bar width (X dimension) in pixel
barcode.X = 1
' Set barcode bar height (Y dimension) in pixel
barcode.Y = 60
' Draw & print generated barcode to png image file
barcode.drawBarcode("C://vbnet-code39.png")
Draw and Print
绘图和打印
Dim qrCode As OnBarcode.Barcode.QRCode
' Create QRCode object
qrCode = New OnBarcode.Barcode.QRCode()
' Set QR Code data to encode
qrCode.Data = "VB.NET QRCode"
' Set QRCode data mode (QR-Code Barcode Settings)
qrCode.DataMode = OnBarcode.Barcode.QRCodeDataMode.Auto
' Draw & print generated QR Code to jpeg image file
qrCode.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
qrCode.drawBarcode("C://vbnet-qrcode.jpg")
回答by bobbell2
You can generate and output the code128 images in VB programming with this code . Refer to the following Visual Basic sample code,you can try to generate code128 in vb.net.
您可以使用此代码在VB编程中生成并输出code128图像。参考下面的Visual Basic示例代码,你可以尝试在vb.net中生成code128。
VB Sample code
VB 示例代码
Dim code128 As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto
code128.CodeToEncode = "0128"
'Apply checksum for Code 128 barcode.
code128.ChecksumEnabled = True
'Display checksum in the Code 128 barcode text
code128.DisplayChecksum = True
'Unit of measure, Pixel, Cm and Inch supported.
code128.BarcodeUnit = KeepAutomation.Barcode.BarcodeUnit.Pixel
'Code 128 image resolution in DPI.
code128.DPI = 72
'Set Size for Generated Code 128 image
'Code 128 bar module width (X dimention)
code128.X = 2
'Code 128 barcode image width (X dimention)
code128.BarCodeWidth = 100
'Code 128 bar module height (Y dimention)
code128.Y = 60
'Image left margin size, a 10X is automatically added according to specification.
code128.LeftMargin = 0
'Image right margin size, a 10X is automatically added according to specification.
code128.RightMargin = 0
'Code 128 image top margin size'
code128.TopMargin = 0
'Code 128 image bottom margin size'
code128.BottomMargin = 0
'Orientation, 90, 180, 270 degrees supported' Code 128 image bottom margin size
code128.Orientation = KeepAutomation.Barcode.Orientation.Degree0
'Code 128 image formats in Png, Gif, Jpeg/Jpg, Tiff, Bmp/Bitmap, etc.
code128.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
'Set Code 128 human readable text style
code128.DisplayText = True
code128.TextFont = New Drawing.Font("Arial", 10.0F, Drawing.FontStyle.Regular)
'Space between barcode and text
code128.TextMargin = 6
code128.generateBarcodeToImageFile("C://code128-vb-net.png")
回答by Donny McCoy
You need to question your goal. That answer will drive your methodology.
你需要质疑你的目标。该答案将推动您的方法论。
- Rapid development and completion
- Learning experience
- Cheap / free (sweat-equity excluded)
- 快速开发和完成
- 学习经验
- 便宜/免费(不包括汗水)
Your google link shows a product that displays sample code on that very page. What's wrong with that?
您的 google 链接显示了在该页面上显示示例代码的产品。那有什么问题?
What is your target output? A report object, or will you print directly to the printer/label?
你的目标输出是什么?报告对象,还是直接打印到打印机/标签?