各位专家好,
我用如下的代码生成条形码并打印,但是输出的条码很模糊,不知道是什么原因。
请指教。谢谢!
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()