以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 条形码问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=148512) |
||||
-- 作者:edisontsui -- 发布时间:2020/4/9 10:58:00 -- 条形码问题 附页是我的代码和打印出的结果,但是条形码有两个问题:1、老是无法调整条形码的宽度和高度、2、条形码下面的字符串最后面老是有一个字母结尾,我想去掉这个字母。请教如何处理。谢谢。
|
||||
-- 作者:有点蓝 -- 发布时间:2020/4/9 11:10:00 -- 打开条形码生成器,进行各种设置,然后查看代码 |
||||
-- 作者:edisontsui -- 发布时间:2020/4/9 13:24:00 -- Dim doc As New PrintDoc \'定义一个报表 doc.PageSetting.Width = 104 doc.PageSetting.Height = 54 Doc.PageSetting.LeftMargin = 1 Doc.PageSetting.RightMargin = 1 Doc.PageSetting.TopMargin = 1 Doc.PageSetting.BottomMargin = 1 Dim n As Integer = CurrentTable.Rows.Count - 1 For i As Integer = 0 To n Dim r As Row = CurrentTable.Rows(i) Dim s1 As Integer = Val(r("数量个")) Dim ra As New prt.RenderArea Dim rt As New prt.RenderText ra.Width = "Parent.Width" ra.Height = "Parent.height" ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never Dim Bar As New BarCodeBuilder Dim img As prt.RenderImage Bar.Symbology = Barpro.Symbology.Code39 Bar.BarRatio = 0.3 \'宽窄比例 bar.barwidth = 0.1 \'窄条宽度 Bar.BarHeight = 36 \'条码高度 Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight For o As Integer = 1 To s1 ra = New prt.RenderArea ra.Width = "Parent.Width" ra.Height = "Parent.height" ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'===============以下逐个定义内容 rt = New prt.RenderText rt.Text = r("产品型号") rt.x = 2 rt.y = 1 rt.Style.Font = New Font("Arial",14,FontStyle.Bold) ra.Children.Add(rt) \'绘制第1条线条 Dim Line As New prt.LineDef(0.5, Color.black) Dim ln As New prt.RenderLine(2,9, 102, 9, Line) ra.Children.Add(ln) \'将线条加入到报表中 \'绘制第2条线条 Dim Line2 As New prt.LineDef(0.5, Color.black) Dim ln2 As New prt.RenderLine(2,17.2, 102, 17.2, Line2) ra.Children.Add(ln2) \'将线条加入到报表中 \'绘制第2条型码 Dim dt1 As String = Format(Date.now,"yyyyMMddHHmmssfff") Dim dt2 As String = dt1.substring(2,6) & "-" & dt1.substring(12,4) Bar = New BarCodeBuilder img = new prt.RenderImage Bar.Code = dt2 img.Image = bar.GetImage img.x = 1.5 img.y = 18 ra.Children.Add(img) rt = New prt.RenderText rt.Text = "1" rt.x = 37 rt.y = 18 rt.Style.Font = New Font("Arial",14) ra.Children.Add(rt) rt = New prt.RenderText rt.Text = "PC" rt.x = 47 rt.y = 18 rt.Style.Font = New Font("Arial",14) ra.Children.Add(rt) rt = New prt.RenderText rt.Text = "RUN" rt.x = 69 rt.y = 18 rt.Style.Font = New Font("Arial",14) ra.Children.Add(rt) rt = New prt.RenderText rt.Text = r("箱号") rt.x = 90 rt.y = 20 rt.Style.Font = New Font("Arial",14) ra.Children.Add(rt) rt = New prt.RenderText rt.Text = r("销售订单号") rt.x = 37 rt.y = 25 rt.Style.Font = New Font("Arial",14) ra.Children.Add(rt) \'绘制第3条线条 Dim Line3 As New prt.LineDef(0.5, Color.black) Dim ln3 As New prt.RenderLine(2,33, 102, 33, Line3) ra.Children.Add(ln3) \'将线条加入到报表中 Doc.Body.ChildRen.Add(ra) Next Next Doc.Preview() \'预览报表 我试过上述代码了,我不断调整 Bar.BarRatio、bar.barwidth 、Bar.BarHeight 三个参数的值,条形码大小都不会发生任何变化。 另外,我的第二个问题(见1楼压缩档案里面)不知道是什么原因?
|
||||
-- 作者:有点蓝 -- 发布时间:2020/4/9 13:56:00 -- 看2楼,条码有几十项设置,麻烦全部试一遍,看看每个设置都是干嘛用的 |
||||
-- 作者:edisontsui -- 发布时间:2020/4/9 15:50:00 -- 终于知道是什么原因了:1、Bar.BarRatio = 0.3、bar.barwidth = 0.1、Bar.BarHeight = 36 这些代码放的位置不对,2、不要显示校验码。 |