wpf中的条形码生成器
在wpf中生成各种类型的条形码的最佳方法是什么?
What the best method to genearate barcode in various type in wpf.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在wpf中生成各种类型的条形码的最佳方法是什么?
What the best method to genearate barcode in various type in wpf.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
条形码字体是一种简单的方法,但部署起来可能很困难,因为客户可能需要在运行应用程序的每台计算机上安装该字体。这可能不切实际,特别是对于 XBAP、Silverlight 和 WinPhone7 部署。
在 WPF 中自己生成条形码非常容易。虽然它可以用纯 XAML 完成,但我发现使用 XAML 和代码的混合是最简单的。
从接受字符并返回条形画笔和宽度的转换器开始:
现在构建条形的 XAML 很简单:
BarcodeTemplate 可以与 ContentPresenter 一起使用来显示任何字符串,例如:
或者
我认为这个解决方案是在 WPF 中生成条形码的“最佳方法”,因为:
Barcode fonts are an easy way to do it, but they can be difficult to deploy because the customer will probably need the font installed on each machine that runs your application. This can be impractical, particularly for XBAP, Silverlight, and WinPhone7 deployments.
It is quite easy to generate the barcodes yourself in WPF. Although it can be done in pure XAML, I find it simplest using a mixture of XAML and code.
Start with a converter that takes a character and returns the bar brushes and widths:
Now the XAML to construct the bars is trivial:
The BarcodeTemplate can be used with a ContentPresenter to display any string, for example:
or
I would argue that this solution is the "best method" to generate barcodes in WPF because:
以下是我最终得到的:
我在github中创建了一个开源控件: https://github.com/KevinPan/wpf-barcode< /a>,请尝试。
希望这有帮助。
The following is what I have finally:
And I have created an open source control in github: https://github.com/KevinPan/wpf-barcode, please try.
Hope this helps.
也许最简单的方法是使用条形码字体。例如:
本示例使用字体“IDAutomationHC39M”。生成的条形码如下所示:
此网页列出了各种免费软件或共享软件条形码字体: http://www.adams1.com/fonts.html 。
Probably the easiest way is to use barcode fonts. For example:
This example uses the font "IDAutomationHC39M". The resulting barcode looks like this:
This web page lists various freeware or shareware barcode fonts: http://www.adams1.com/fonts.html .