代码如下:
内容预览的时候是横的,纸张也是横的,打印机怎么设置都是只打印竖的 ,更改了打印机器属性也无用
Dim doc As New PrintDoc() '定义一个报表
Doc.PageSetting.LeftMargin = 1 '设置左边距
Doc.PageSetting.RightMargin =1 '设置右边距
Doc.PageSetting.TopMargin = 1 '设置上边距
Doc.PageSetting.BottomMargin = 1 '设置下边距
Dim rt As prt.RenderText '定义一个文本对象
Dim bg As New prt.RenderTable() '定义一个表格对象
doc.Body.Children.Add(bg ) '将表格对象加入到报表中
bg .Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg .Width = 88 '表宽为150毫米
bg .Height = 58 '表高为150毫米
bg .Rows.Count = 5 '设置行数
bg .Cols.Count = 4 '设置列数
bg.Cols(0).Width = 10
bg.Cols(1).Width = 30
bg.Cols(2).Width = 10
bg.Cols(3).Width = 30
bg.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
bg.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
bg.Style.WordWrap = True
bg.Cells(0, 0).Text="用途"
bg.Cells(0, 1).Text="涉密计算机专用办案"
bg.Cells(0, 2).Text="密级"
bg.Cells(0, 3).Text="机密"
bg.Cells(1, 0).Text="部门"
bg.Cells(1, 1).Text="信息技术保障"
bg.Cells(1, 2).Text="房号"
bg.Cells(1, 3).Text="信息技术保障室1036"
bg.Cells(2, 0).Text="型号"
bg.Cells(2, 1).Text="联想m4700pc"
bg.Cells(2, 2).Text="IP地址"
bg.Cells(2, 3).Text="192.168.244.123"
bg.Cells(3, 0).Text="责任人"
bg.Cells(3, 1).Text="周x"
bg.Cells(3, 2).Text="编号"
bg.Cells(3, 3).Text="waxjwzd6768768"
bg.Cells(4, 0).Text="涉密专用机,严禁非法外联"
bg.Cells(4,0).SpanCols = 4 '第5行第2个单元格向右合并3列
doc.AutoRotate = False
doc.PageSetting.Landscape = True
doc.PageSetting.Width = 90 '纸张宽度为100毫米
doc.PageSetting.Height = 60 '纸张高度为120毫米
'Doc.PrinterName = "ZDesigner GK888t (EPL)"
'doc.Print()
doc.Preview() '预览