Dim dr As DataRow = Args(0)'打印内容
Dim t As String = "打印" '操作类型 打印 / 预览
Dim num As Integer = args(1)'打印份数
Dim printname As String = args(2) '打印名
Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
doc.PageSetting.Width = 50 '纸张宽度为60毫米
doc.PageSetting.Height = 30 '纸张高度为40毫米
Doc.PageSetting.LeftMargin = 0 '设置左边距
Doc.PageSetting.RightMargin = 0 '设置右边距
Doc.PageSetting.TopMargin = 0 '设置上边距
Doc.PageSetting.BottomMargin = 0 '设置下边距
doc.AutoRotate = False '禁止自动旋转打印内容
Dim fntx As New Font("微软雅黑",12,FontStyle.Bold )
Dim ra As New prt.RenderArea
Dim rt As prt.RenderText
ra.Width = 50 '宽度60毫米
ra.Height = 30 '高度40毫米
ra.Style.Spacing.All = 1
'ra.Style.Borders.All = New prt.Linedef(0.3, Color.Red) '设置边框
ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never '禁止水平分割
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止垂直分割
Doc.Body.ChildRen.Add(ra) '将容器加入到报表中
Dim fnt As New Font("微软雅黑",14)
Dim fnt1 As New Font("微软雅黑",12)
'rt = New prt.RenderText
'rt.Text = "款号:"
'rt.Width = "Auto" '自动设置宽度
'rt.X = 2
'rt.Y = 1
'rt.Style.Font = fnt
'ra.Children.Add(rt) '添加到容器中
'品牌内容
'rt = New prt.RenderText
'rt.Text = dr("itemNo")
'rt.Width = "Auto" '自动设置宽度
'rt.X = "Prev.Right"
'rt.Y = "Prev.top"
'rt.Style.Font = fnt
'ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text = "规格:"
rt.Width = "Auto" '自动设置宽度
rt.X = 2
rt.Y = 1 '"Prev.Bottom"
rt.Style.Font = fnt
ra.Children.Add(rt) '添加到容器中
rt = New prt.RenderText
rt.Text = dr("colour").TRIM() & dr("size").TRIM()
rt.Width = "Auto" '自动设置宽度
rt.X = "Prev.right"
rt.Y = "Prev.top"
rt.Style.Font = fnt
ra.Children.Add(rt)
Dim Bar As New BarCodeBuilder
Dim rg As New prt.RenderGraphics
rg = new prt.RenderGraphics
Bar.Symbology = Barpro.Symbology.Code128
bar.Code = dr("barcode")
Bar.BarRatio = 0.2648
Bar.QuietZoneWidth = 0
Bar.DisplayCode = False
Bar.AddCheckSum = False
Bar.DisplayStartStopChar = False
Bar.BarHeight = 16
rg.width = 50
rg.height = 16
bar.DrawOnCanvas(rg.Graphics,0,0,1)
rg.X = 0
rg.y = "Prev.Bottom"
rg.Style.ImageAlign.AlignHorz=prt.ImageAlignHorzEnum.Center
ra.Children.Add(rg)
rt = New prt.RenderText
rt.Text = dr("barcode")
rt.Width = 50
rt.X = 1
rt.Y = "Prev.Bottom"
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.Font = fnt1
ra.Children.Add(rt)
Dim ps As new System.Drawing.Printing.PrinterSettings
If t = "打印"
Doc.PrinterName = printname
ps.Copies = num '设置份数
doc.Print(ps)
Else
Doc.PrinterName = printname
Doc.Preview
End If