e.Form.Page.Width = 241 '纸张宽度为XX毫米
e.Form.Page.Height = 139.7 '纸张高度为XX毫米
e.Form.Page.LeftMargin = 25 '设置左边距
e.Form.Page.RightMargin = 25 '设置右边距
e.Form.Page.TopMargin = 10 '设置上边距
e.Form.Page.BottomMargin = 10 '设置下边距
Dim doc As PrintDoc = e.Form.GernatePrintDoc()
doc.AutoRotate = False '禁止自动旋转打印内容
For Each c As object In Doc.Body.Children
If c.Gettype.Name Like "*Table*" Then
Dim t As prt.RenderTable = c
For i As Integer = 0 To t.Rows.Count - 1
If t.Cells(i, 2).Text = Nothing AndAlso t.Cells(i, 1).Text <> Nothing Then
t.Cells(i, 1).SpanCols = 5
End If
Next
End If
Next
Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = "上海昌硕金属新材料有限公司"
rx.Cells(1,0).Text = "原料入库通知单"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '设置居中
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Cells(0,0).Style.FontSize = 16 '设置字体大小
rx.Cells(1,0).Style.FontSize = 14 '设置字体大小
Doc.PageHeader = rx '作为页眉使用
Dim rx1 As New prt.RenderTable
rx1.Cells(0,0).Text = "制单:" & MainTable.Current("录入人")
rx1.Cells(0,1).Text = "制单时间:" & MainTable.Current("录入时间")
rx1.Cells(0,2).Text = "打印日期:" & Date.Today
rx1.Cells(1,0).Text = " "
rx1.Cells(2,0).Text = "一式四联: 【白色】 财务 【红色】 统计"
rx1.Cells(2,1).Text = "【蓝色】 营销 【黄色】 仓库 "
rx1.Cells(2,2).Text = "第[PageNo]页,共[PageCount]页"
rx1.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx1.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx1.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx1.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx1.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = rx1 '作为页脚使用
doc.Preview() '预览