Dim doc As New PrintDoc() '定义一个报表
doc.PageSetting.Width = 100 '纸张宽度为76毫米
doc.PageSetting.Height = 120 '纸张高度为102毫米
doc.PageSetting.LeftMargin = 2 '设置左边距
doc.PageSetting.TopMargin = 1 '设置上边距
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rx As New prt.RenderText '定义一个文本对象
Dim ra As New prt.RenderArea '定义一个容器
Dim ra1 As New prt.RenderArea '定义一个容器
Dim rm As prt.RenderImage '定义一个图片对象
For Each r As Row In Tables("条码").Rows
Dim n As Integer = 0
n = n + 1
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分
rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
rt.Width = 90 '表格宽度为 72mm
rt.Height = 110 '设置表格的高度 95mm
rt.Rows.Count = 5 '设置总行数 0为第一行
rt.Cells(1,0).SpanCols = 8
Dim img As prt.RenderImage
Dim Bar As New BarCodeBuilder '定义一个条码对象
Bar.Symbology = Barpro.Symbology.Code128 '128格式条码
ra1 = rt.Cells(n,0).Area '引用单元格的容器,第2行
bar.Code = r("编号")
bar.Text = r("编号") & r("产品名称") & r("产品型号")
bar.BarWidth = 0.48 '窄条宽度
bar.BarRatio = 0.5 '条码宽窄比例
bar.BarHeight = 8 '条码高度
Bar.QuietZoneWidth = 2 '静区宽度
Bar.CodeAlignment = Barpro.Alignment.BelowJustify
Bar.BottomMargin = 1 '条码离文字底下距离
Bar.Font = New Font("宋体",12,FontStyle.Bold)
rm = new prt.RenderImage
rm.Image = bar.GetImage
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
ra1.Children.Add(rm) '加入文本到RenderArea中
doc.Body.Children.Add(rt)
Next
doc.Preview() '预览报表