William 的个人资料.Net Zone日志列表 工具 帮助
1月28日

Use MicrosoftReportViewer and a Dymo LabelWriter to create a really nice and 3of9 barcode label

I have to say, I had fun coding this feature.  I wanted to print some 3of9 bar code labels for employee badges in a WinForms app I am rolling out. I was thinking this was going to involve some custom api and buying some font package (some are big $$). It turned out this was surprisingly simple and a fun report to build. Here is a sample label (extra points for first person to discover what is the barcode:

  image  

What you need:

  1. SqlServer or some other data source.  I am using Linq and Entity Framework. You could you XML, csv or memory objects as you need.
  2. Visual Studio and the MicrosoftReportViewer control. Not sure if this is included in Express addition or not. Let me know.
  3. A Dymo LabelWriter 400 or other such printer that can print single labels in a stream. I really like the Dymo for its ease of use, simple loading, and it is well made.  Also it is a thermal printer, so you don't need to change any ribbons - ever.  About $100.  Order the label sizes you need - remember you need to order their special labels as they are thermal. I am using 3.5" x 1".  I also like this, because you don't waste a lot of labels like trying to print 8.5"x11" sheets.  You always end up with half a sheet you don't know what to do with.  So get a Dymo, you can use it for other things too.
  4. A 3of9 TrueType font. I use the Free3of9 ttfs here: http://www.squaregear.net/fonts/free3of9.shtml.  Hats off to Matthew Welch for his nice font package he is sharing!
    Just download and install the two fonts from the Control panel.

Steps to create the label report.  I am using 3.5" x 1" labels, but same steps apply for other sizes:

  1. Install the Free3of9 fonts and logout and back in to get the fonts loaded.
  2. Create a VS WinForms project. You could do the same with WPF, but I used WinForms.
  3. Add a new Form to hold your report control.
  4. Add a MicrosoftReportViewer control to the form. I have to give props to MS for this control. It is a great control that puts a lot of power in your hands.
  5. Create a new report from the drop down on the top right of the control.
  6. Once your in the designer, change the report properties Layout to 3.4in wide and .9in high.  I set it just a tad smaller then the label so as not to get strange page breaks.  Set all four margins to 0.
  7. Change the Body of the report surface to 3.4 x .9in or smaller. Just don't make it larger then the page layout or you will get page breaks
  8. Now your surface is your "label".  Add your Table and other controls as needed for your label within this surface.
  9. Change the font family to 3of9 Extended for the field that you want to show as a barcode.
  10. Add as many Detail rows to your table as you need vertically.  I used 2 rows to show Employee name on top and EmployeeID as Barcode under it.
  11. Select the last row and right-click "Edit Group..." and group on some unique field such as employee id.  Also Check "Page break at end." so that your page will break to a new label after each employee.
  12. In the load event of the form, get your data as a list and set the DataSource property of the report control to the list and RefreshReport() after that.
  13. Run your report and adjust things as needed.  Fast, clean and professional barcodes in a snap right from your next windows application.

Misc:

  • Set the Dymo Advanced properties on the printer driver to "Barcodes and images" to get really clean quality. Set the Color to black and white, not sure why they have a Color option, but you can play with output as needed.
  • Can also use this same method to make a production receipt printer application with the Dymo with full graphics abilities.  Just get the Receipt paper they offer and change the report size.
  • Not sure how to make it print directly to a printer without user intervention yet.  Say you wanted a receipt to print after clicking a button and not show the print dialog.  If anyone knows how to make ReportViewer do this, please let me know.
  • Have fun with your new 3of9 labels!  I will try to add some pictures here and a sample project soon.
  • When I get my USB barcode scanner with Serial simulation driver, I hope to post back with some code showing how to use the Serial class so we can scan our new labels.

--William

评论 (1)

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

若要添加评论,请使用您的 Windows Live ID 登录(如果您使用过 Hotmail、Messenger 或 Xbox LIVE,您就拥有 Windows Live ID)。登录


还没有 Windows Live ID 吗?请注册

没有名字发表:
http://www.batteryfast.com.au/acer/travelmate-4000.htm acer travelmate 4000 battery ,
http://www.batteryfast.com.au/acer/travelmate-3002wtci.htm acer travelmate 3002wtci battery ,
http://www.batteryfast.com.au/acer/travelmate-3002wtmi.htm acer travelmate 3002wtmi battery ,
http://www.batteryfast.com.au/acer/travelmate-3200.htm acer travelmate 3200 battery ,
http://www.batteryfast.com.au/acer/lip6179qupcsy6.htm acer lip6179qupcsy6 battery ,
http://www.batteryfast.com.au/acer/batbl50l6.htm acer batbl50l6 battery ,
http://www.batteryfast.com.au/acer/travelmate-4200.htm acer travelmate 4200 battery ,
http://www.batteryfast.com.au/acer/aspire-5100.htm acer aspire 5100 battery ,
http://www.batteryfast.com.au/acer/aspire-3690.htm acer aspire 3690 battery ,
http://www.batteryfast.com.au/acer/aspire-5680.htm acer aspire 5680 battery ,
http://www.batteryfast.com.au/acer/aspire-9120.htm acer aspire 9120 battery ,
http://www.batteryfast.com.au/acer/um08a71.htm acer um08a71 battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a110l-series.htm acer black aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a150l-series.htm acer black aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a150x-series.htm acer black aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-zg5.htm acer black aspire one zg5 battery ,
http://www.batteryfast.com.au/acer/um08a72.htm acer um08a72 battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a110l-series.htm acer blue aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a150l-series.htm acer blue aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a150x-series.htm acer blue aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-zg5.htm acer blue aspire one zg5 battery ,
http://www.batteryfast.com.au/acer/um08a73.htm acer um08a73 battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a110l-series.htm acer white aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a150l-series.htm acer white aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a150x-series.htm acer white aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-zg5.htm acer white aspire one zg5 battery ,
http://www.batteryfast.com.au/acer/um08a74.htm acer um08a74 battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a110l-series.htm acer black aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a150l-series.htm acer black aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-a150x-series.htm acer black aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/black-aspire-one-zg5.htm acer black aspire one zg5 battery ,
http://www.batteryfast.com.au/acer/um08b72.htm acer um08b72 battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a110l-series.htm acer blue aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a150l-series.htm acer blue aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-a150x-series.htm acer blue aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/blue-aspire-one-zg5.htm acer blue aspire one zg5 battery ,
http://www.batteryfast.com.au/acer/um08b73.htm acer um08b73 battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a110l-series.htm acer white aspire one a110l series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a150l-series.htm acer white aspire one a150l series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-a150x-series.htm acer white aspire one a150x series battery ,
http://www.batteryfast.com.au/acer/white-aspire-one-zg5.htm acer white aspire one zg5 battery ,
http://www.batteryfast.com.au/apple/a1022.htm apple a1022 battery ,
http://www.batteryfast.com.au/apple/a1079.htm apple a1079 battery ,
http://www.batteryfast.com.au/apple/m9324.htm apple m9324 battery ,
http://www.batteryfast.com.au/apple/a1078.htm apple a1078 battery ,
http://www.batteryfast.com.au/apple/a1045.htm apple a1045 battery ,
http://www.batteryfast.com.au/apple/m9325.htm apple m9325 battery ,
http://www.batteryfast.com.au/apple/m9756.htm apple m9756 battery ,
http://www.batteryfast.com.au/apple/a1175.htm apple a1175 battery ,
http://www.batteryfast.com.au/apple/ma348g-a.htm apple ma348g a battery ,
3 月 10 日

引用通告

引用此项的网络日志