e.Form.Page.PaperKind = 9 '纸张类型改为A4
e.Form.Page.Landscape = True '横向打印
e.Form.Page.LeftMargin = 10 '设置左边距
e.Form.Page.RightMargin = 10 '设置右边距
e.Form.Page.TopMargin = 10 '设置上边距
e.Form.Page.BottomMargin = 10 '设置下边距
Dim grp As WinForm.SplitContainer = e.Form.Controls("SplitContainer1")
Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp.Panel1)
For Each c As object In Doc.Body.Children
If Typeof c Is prt.RenderTable Then
Dim t As prt.RenderTable = c
For i As Integer = 0 To t.Rows.count-1
t.Rows(i).Height = "Auto"
Next
End If
Next
一些判断的代码没贴
doc.AutoRotate = False '禁止自动旋转打印内容
'设置页眉
Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = "南通益纬物流有限公司"
rx.Cells(5,0).Text = "运输记录汇总表"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
'rx.Style.Borders.Bottom = New prt.LineDef '设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Style.FontSize = 10 '字体大小为8磅
Doc.PageHeader = rx '作为页眉使用
doc.PageSetting.TopMargin = 15
'设置页脚
Dim tx As New prt.RenderTable
tx.Cells(0,0).Text = "打印日期:" & Date.Today
tx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
tx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
tx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
tx.Style.Borders.top = New prt.LineDef '设置底边框
tx.CellStyle.Spacing.top = 0.5 '底端内容缩进0.5毫米
tx.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = tx '作为页脚使用
doc.Preview()
[此贴子已经被作者于2022/6/10 17:17:02编辑过]