以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]打印出的条形码很模糊  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=55858)

--  作者:mickeygy
--  发布时间:2014/8/25 10:59:00
--  [求助]打印出的条形码很模糊

各位专家好,

       我用如下的代码生成条形码并打印,但是输出的条码很模糊,不知道是什么原因。

        请指教。谢谢!

 

Dim doc As New PrintDoc
doc.PageSetting.Width = 200
doc.PageSetting.Height = 200 \'页面高
Doc.PageSetting.LeftMargin = 0 \'标签框架左边距
Doc.PageSetting.rightMargin = 0 \'标签框架右边距
Doc.PageSetting.TopMargin = 0 \'标签框架上边距
Doc.PageSetting.BottomMargin = 0
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
Dim ra As New prt.RenderArea
Dim rt As prt.RenderText
ra.Width = 200 \'标签框架宽
ra.Height = 200 \'标签框架高
ra.Style.Spacing.all = 2
ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never
Doc.Body.ChildRen.Add(ra)
\'\'\'\'\'\'\'\'\'\'\'\'\'SN 显示
rt = New prt.RenderText
rt.Text = e.Form.Controls("TXT").TEXT \'SN显示
rt.Style.Font = New Font("Arial", 7 ,FontStyle.Regular)   \'粗体FontStyle.Bold   常规FontStyle.Regular
rt.X =10
rt.Y =20
ra.Children.Add(rt)

\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'二维码打印生成
Dim rpar As New prt.RenderParagraph()
Dim img As prt.RenderImage

\'\'\'\'\'\'\'\'条码生成\'\'\'\'\'\'\'\'\'


Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.Code128
Bar.Code = e.Form.Controls("txt").Text
Bar.QuietZoneWidth = 2
Bar.TextFont = New Font("宋体",9)


\'\'\'\'\'\'\'\'\'\'\'\'\'
img = new prt.RenderImage
  img.Image = bar.GetImage
Dim rm As New prt.RenderImage \'定义一个条码图片对象
rm.Image =bar.getimage \'设置条码图片
rm.Width = "Auto" \'宽度等于页面宽度
rm.Height = "Auto" \'高度由条码图片大小自动决定
rm.Style.ImageAlign.StretchHorz = False \'禁止条码图片水平拉伸
\'rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center \'水平居中
rm.X= 0
rm.y= 0
ra.Children.Add(rm)

Doc.Preview()


--  作者:有点甜
--  发布时间:2014/8/25 11:01:00
--  

 1、你先用工具设计好条形码

 

 2、拷贝【查看代码】的代码进去,看看效果


--  作者:狐狸爸爸
--  发布时间:2014/8/25 11:25:00
--  

用这个方法,就清晰了:

http://www.foxtable.com/help/topics/2093.htm