Dim doc As New PrintDoc \'定义一个报表
Dim rt As prt.RenderTable\'定义一个表格对象
Dim tb As Table = Tables("订单表.订单明细")
Dim tbl As Table = Tables("订单表")
doc.PageSetting.Width = 241 \'纸张宽度为200毫米
doc.PageSetting.Height = 93 \'纸张高度为170毫米
doc.AutoRotate = False \'如果纸张的宽度超过高度,要加上这行代码
doc.PageSetting.TopMargin= 5
doc.PageSetting.BottomMargin =5
doc.PageSetting.LeftMargin= 5
doc.PageSetting.RightMargin =5
\'设置主标题
rt = New prt.RenderTable
rt.BreakBefore = prt.BreakEnum.Page \'另起一页再打印
rt.Style.GridLines.All = New prt.Linedef \'设置网格线
rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米
rt.Cells(0,0).text = "高福食品销售出库单"
rt.Cells(0,0).SpanCols = 6 \'合并第一行全部单元格,用于显示主标题
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
rt.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) \'设置主标题字体
\'设置副标题
rt.Cells(1,0).text = "客户名称:" & tbl.Current("客户名称") \'通过左边空格数量来调整副标题位置
rt.Cells(1,0).Spancols = 2 \'合并地二行全部单元格,用于显示副标题
rt.Cells(1,0).Style.Borders.Right = New prt.LineDef("0mm", Color.white)
rt.Cells(1,2).text = "出库日期:" & tbl.current("出库日期") \'通过左边空格数量来调整副标题位置
rt.Cells(1,2).Spancols = 2 \'合并地二行全部单元格,用于显示副标题
rt.Cells(1,2).Style.Borders.Right = New prt.LineDef("0mm", Color.white)
rt.Cells(1,4).text = "出库单号:" & tbl.Current("订单编号") \'通过左边空格数量来调整副标题位置
rt.Cells(1,4).Spancols = 2
rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线
rt.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white)\'去掉第二行的网格线
rt.Rows(1).Style.Borders.Bottom = New prt.Linedef \'恢复第二行底端的网格线
rt.Rows(1).Height = 8 \'设置第二行的高度,拉开和表格主体的距离.
rt.RowGroups(0,1).Style.TextAlignVert = prt.AlignVertEnum.Center \'第一行内容垂直居中
rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All \'将第一行作为表头.
rt.RowGroups(3,1).DataBinding.DataSource = BindTables("订单表.订单明细") \'将第二行绑定到订单表
Dim ColNames As String() = New String(){"产品名称", "规格","单位", "价格","数量","金额"}
For c As Integer = 0 To Colnames.Length -1
rt.Cells(2,c).Text = ColNames(c)
rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth
rt.Cells(3, c).Text = "[Fields!" & ColNames(c) & ".Value]" \'设置绑定表达式
Next
rt.cells(rt.Rows.count,0).text= "金额合计:" & tbl.Current("订单金额") & "元"
rt.cells(rt.Rows.count-1,0).SpanCols= 6
rt.cells(rt.Rows.count-1,0).Style.TextAlignHorz = prt.AlignHorzEnum.right
doc.Body.Children.Add(rt)
Doc.Preview
此主题相关图片如下:打印首选项的设置.png

代码 没有问题 a4 纸能正常打印,,但针式就不行了。搞不明白
此主题相关图片如下:实际打印效果.jpg
