以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助] 显示打印页数  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=154652)

--  作者:sanny
--  发布时间:2020/9/22 8:06:00
--  [求助] 显示打印页数
老师,如附图,如何把打印预览中的页数加到如下代码中 ? 每张显示格式 “ 第xx页,总页数xx”,谢谢。

Dim count As Integer = 1
If InputValue(count, "提示", "打印多少次?") Then
    If count < = 100 Then
        Dim doc  As New PrintDoc
        doc.PageSetting.Width = 69  \'
        doc.PageSetting.Height = 42
        Doc.PageSetting.LeftMargin = 3
        Doc.PageSetting.TopMargin = 3
        Doc.PageSetting.RightMargin = 0
        Dim t As Table = e.form.controls("Table1").Table
        
        For j As Integer = 1 To count
            
            For i As Integer = t.TopPosition To t.BottomPosition
                Dim r As Row = t.Rows(i)
                r("printtimes") = count
                r("printtime") = now ()
                
                
                Dim rt As New prt.RenderTable() \'定义一个表格对象
                Dim rt1 As New prt.RenderText
                rt1.Style.FontBold = True
                rt.Style.FontSize = 10
                rt.Rows(0).Height = 6
                rt.Rows(1).Height = 6
                rt.Rows(2).Height = 6
                rt.Rows(3).Height = 6
                \'rt.Rows(4).Height = 3
                
                rt.Style.Spacing.bottom = 3
                rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'避免垂直换页的时候,表格被分割成两部分.
                rt.Cols(0).Width = 25
                rt.Cols(1).Width = 45
                rt.cells(0,0).Text = "Customer:"
                rt.Cells(0,1).Text = r("EndCustomer")
                rt.Cells(1,0).Text= "Part No.:"
                rt.Cells(1,0).Style.WordWrap = False
                rt.cells(1,1).Text = r("PartNo")
                rt.Cells(2,0).Text= "GSS Part No.:"
                rt.cells(2,1).Text = r("GSSPart")
                rt.Cells(3,0).Text= "Qty:"
                rt.cells(3,1).Text = r("OpenQty")& "  PCS"
                
                rt.cells(4,0).SpanCols =2
                
                doc.Body.Children.Add(rt) \'将表格对象加入到报表中
                Dim  rg As prt.RenderGraphics
                Dim  Bar As  New   BarCodeBuilder
                
                Bar.Symbology =   Barpro.Symbology.Code128
                bar.Code =  r("PartNo")
                Bar.Text = Date.Today
                rg =  new  prt.RenderGraphics
                rt.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center
                
                rg.Height = 12
                
                bar.DrawOnCanvas(rg.Graphics,0,0,1)
                rt.cells(4,0).RenderObject = rg
            Next
            
        Next
        
        doc.Preview()
        
        
        Dim t1 As Table = Tables("Orderlist")
        Dim nmb() As String = {"GSSAG_PO","Endcustomer","CustomerPO","GSSPart","PartNo","OpenQty","ETD","Printtimes","PrintTime"}
        Dim nma() As String = {"GSSAG_PO","Endcustomer","CustomerPO","GSSPart","PartNo","OPENQty","ETD","Printtimes","PrintTime"}
        
        For r As Integer = t1.TopPosition To t1.BottomPosition
            Dim dr As Row = Tables("PrintHistory").AddNew
            For i As Integer = 0 To nma.Length - 1
                dr(nma(i)) = t1.rows(r)(nmb(i))
            Next
        Next
        
    Else
        msgbox("一次打印不可以大于100张")
        
    End If
End If

DataTables("PrintHistory").Save()
[此贴子已经被作者于2020/10/31 15:04:29编辑过]

--  作者:有点蓝
--  发布时间:2020/9/22 8:56:00
--  
参考:http://www.foxtable.com/webhelp/topics/1197.htm
--  作者:sanny
--  发布时间:2020/10/31 9:16:00
--  
老师,以下增加了以下黄色代码,可是出现的页码打在标签的中间了,如附图,如何让它显示在底部,谢谢。




Dim count As Integer = 1
If InputValue(count, "提示", "打印多少次?") Then
If count < = 100 Then
Dim doc  As New PrintDoc
doc.PageSetting.Width = 69  \'
doc.PageSetting.Height = 42
Doc.PageSetting.LeftMargin = 3
Doc.PageSetting.TopMargin = 3
Doc.PageSetting.RightMargin = 0
Dim t As Table = e.form.controls("Table1").Table

For j As Integer = 1 To count

For i As Integer = t.TopPosition To t.BottomPosition
Dim r As Row = t.Rows(i)
    r("printtimes") = count
    r("printtime") = now ()
    

    Dim rt As New prt.RenderTable() \'定义一个表格对象
    Dim rt1 As New prt.RenderText
    rt1.Style.FontBold = True
    rt.Style.FontSize = 10
    rt.Rows(0).Height = 6
    rt.Rows(1).Height = 6
    rt.Rows(2).Height = 6
    rt.Rows(3).Height = 6
    rt.Style.Spacing.bottom = 3
    rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'避免垂直换页的时候,表格被分割成两部分.
    rt.Cols(0).Width = 25
    rt.Cols(1).Width = 45
    rt.cells(0,0).Text = "Customer:"
    rt.Cells(0,1).Text = r("EndCustomer")
    rt.Cells(1,0).Text= "Part No.:"
    rt.Cells(1,0).Style.WordWrap = False
    rt.cells(1,1).Text = r("PartNo")
    rt.Cells(2,0).Text= "GSS Part No.:"
    rt.cells(2,1).Text = r("GSSPart")
    rt.Cells(3,0).Text= "Qty:"
    rt.cells(3,1).Text = r("OpenQty")& "  PCS"

rt.cells(4,0).SpanCols =2

                doc.Body.Children.Add(rt) \'将表格对象加入到报表中
                Dim  rg As prt.RenderGraphics
                Dim  Bar As  New   BarCodeBuilder

                Bar.Symbology =   Barpro.Symbology.Code128
                bar.Code =  r("PartNo")
Bar.Text = Date.Today
                rg =  new  prt.RenderGraphics
             rt.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center 
   rg.Height = 12

                bar.DrawOnCanvas(rg.Graphics,0,0,1)
                rt.cells(4,0).RenderObject = rg
 
           Next
Next

Dim rrt As prt.RenderText \'定义一个文本对象
rrt = New prt.RenderText \'设置文本对象的内容
rrt.Text = "[PageNo] of [PageCount]" \'设置文本内容
rrt.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐
rrt.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框
rrt.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米
rrt.Style.FontSize = 8 \'字体大小为8磅
Doc.PageFooter = rrt 

doc.Preview()
doc.Print()
Next
Else 
msgbox("一次打印不可以大于100张")
End If 
End If 
DataTables("PrintHistory").Save()
[此贴子已经被作者于2020/10/31 15:04:05编辑过]

--  作者:有点蓝
--  发布时间:2020/10/31 10:41:00
--  
加一句doc.PageSetting.BottomMargin = 3
--  作者:sanny
--  发布时间:2020/10/31 10:58:00
--  
谢谢,老师,可以帮忙再加个条件吗? 如下:

可以选择打印第几页的吗? 默认情况打印全部,如何加这个提示框 ? 谢谢。


--  作者:有点蓝
--  发布时间:2020/10/31 11:06:00
--  
无法选择打印第几页