-- 作者:baoxyang
-- 发布时间:2012/5/28 22:24:00
-- 求教,打印反映速度较慢原因.
Dim doc As New PrintDoc() \'定义一个报表 doc.PageSetting.Width = 90 \'纸张宽度为90毫米 doc.PageSetting.Height = 50 Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.Code39 Bar.BarWidth = 0.33 Bar.BarHeight = 15 Bar.BearerBarWidth = 10 Bar.CodeAlignment = Barpro.Alignment.AboveCenter Bar.DisplayChecksum = False Bar.DisplayStartStopChar = False Bar.Font = New Font("宋体",10) For i As Integer = 0 To s3 -1 Doc.PageSetting.Landscape = True \'横向打印 Dim ra As New prt.RenderArea \'定义一个容器 Dim rt2 As New prt.RenderTable() \'定义一个表格对象
.
.
.
ra1.Children.Add(img1) \'加入图片到RenderArea中 ra2.Children.Add(img2) \'加入图片到RenderArea中 ra.Children.Add(rt2) \'加入到容器中 ra.Children.Add(rt1) \'加入到容器中 Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next Doc.PrinterName = pt doc.Print()
一共只有3页,从开始到打印需要至少40秒种.
请教,产生原因可能是哪方面?谢谢指点!
|
-- 作者:baoxyang
-- 发布时间:2012/5/29 8:38:00
--
贴出全部代码:
Dim st As Date = Date.Now If Vars("权限").Contains("托运管理\\其它管理\\标签打印") = False Then msgbox("无操作权限,请联系管理员!",64,"提示") Return End If Dim cmd As New SQLCommand cmd.C Dim pt As String = Functions.Execute("打印机选择","标签打印") Dim doc As New PrintDoc() \'定义一个报表 doc.PageSetting.Width = 90 \'纸张宽度为90毫米 doc.PageSetting.Height = 50 Doc.PageSetting.LeftMargin = 1 \'设置左边距 Doc.PageSetting.RightMargin = 1 \'设置右边距 Doc.PageSetting.TopMargin = 1 \'设置上边距 Doc.PageSetting.BottomMargin = 1 \'设置下边距 Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.Code93 Bar.BarWidth = 0.33 Bar.BarHeight = 15 Bar.BearerBarWidth = 10 Bar.CodeAlignment = Barpro.Alignment.AboveCenter Bar.DisplayChecksum = False Bar.DisplayStartStopChar = False Bar.Font = New Font("宋体",10) Dim s1,s2,s3,s4,s5,s6,s7 As String Dim r As Row = Tables("S托运单查询_Table1").current s1 = r("条码单号") s2 = r("订单号") s3 = r("货物件数") s4 = r("客户简称") s5 = r("配送点") cmd.commandtext = "select 库位 from {托运配送点} where 简称 = \'"& s5 &"\'" s6 = cmd.ExecuteScalar() If r IsNot Nothing Then For i As Integer = 0 To s3 -1 Doc.PageSetting.Landscape = True \'横向打印 Dim ra As New prt.RenderArea \'定义一个容器 Dim rt2 As New prt.RenderTable() \'定义一个表格对象 rt2.CellStyle.Spacing.All = 1 \'单元格内容缩进1毫米 rt2.Style.Spacing.Bottom = 0 \'和下一个工资条的距离是3毫米 rt2.Rows.Count = 1 \'设置总行数 rt2.Cols.Count = 2 \'设置总列数 rt2.Height = 19 \'设置表格的高度 rt2.Width = 88 \' rt2.Rows(0).Height = 73 rt2.Cols(0).Width = 74 rt2.Cols(1).Width = 282 \' Dim ra1 As New prt.RenderArea \'定义一个容器 \' ra1 = rt2.Cells(0,0).Area Dim ra2 As New prt.RenderArea \'定义一个容器 ra2 = rt2.Cells(0,1).Area Bar.Code = s1 & "-" & i +1 \' Dim img1 As prt.RenderImage \' img1 = new prt.RenderImage \' img1.Image = GetImage("双得力.png") \' img1.Width = 18 \' img1.Height = 18 Dim img2 As prt.RenderImage img2 = new prt.RenderImage img2.Image = bar.GetImage img2.Height = 18
Dim rt1 As New prt.RenderTable() \'定义一个表格对象 rt1.CellStyle.Spacing.All = 1 \'单元格内容缩进1毫米 rt1.Style.Spacing.Bottom = 1 \'和下一个工资条的距离是3毫米 rt1.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt1.Style.TextAlignHorz = prt.AlignHorzEnum.Center rt1.Style.Font = New Font("宋体",11,FontStyle.Bold) rt1.Rows.Count = 3 \'设置总行数 rt1.Cols.Count = 4 \'设置总列数 rt1.Height = 28 \'设置表格的高度 rt1.Width = 87 rt1.Cols(0).Width = 49 rt1.Cols(1).Width = 131 rt1.Cols(2).Width = 49 rt1.Cols(3).Width = 112 rt1.Rows(0).Height = 27 rt1.Rows(1).Height = 37 rt1.Rows(2).Height = 37 rt1.Cells(0,0).Text= s5 rt1.Cells(0,3).Text= s6 rt1.Cells(1,0).Text = "订单号" rt1.Cells(1,1).Text = s2 rt1.Cells(2,0).Text= "商品名称" rt1.Cells(2,1).Text = s4 rt1.Cells(2,2).Text= "箱数编号" rt1.Cells(2,3).Text = s3 & "-" & i +1 & "#" rt1.Cells(0,0).SpanCols = 2 rt1.Cells(1,1).SpanCols = 2 rt1.Cells(0,3).Style.Font = New Font("宋体",14,FontStyle.Bold) rt1.Cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Left rt1.Cells(2,1).Style.Font = New Font("宋体",12,FontStyle.Bold) rt1.Cells(2,3).Style.Font = New Font("宋体",12,FontStyle.Bold) \' ra1.Children.Add(img1) \'加入图片到RenderArea中 ra2.Children.Add(img2) \'加入图片到RenderArea中 ra.Children.Add(rt2) \'加入到容器中 ra.Children.Add(rt1) \'加入到容器中 Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒") \' Dim st1 As Date = Date.Now Doc.PrinterName = pt doc.Print() MessageBox.Show("耗时: " & (Date.Now - st1).TotalSeconds & "秒") End If
|