Foxtable(狐表)用户栏目专家坐堂 → [建议][求助]关于横纵向打印,官方是不是给个最终的解决方案


  共有2682人关注过本帖平板打印复制链接

主题:[建议][求助]关于横纵向打印,官方是不是给个最终的解决方案

帅哥哟,离线,有人找我吗?
huangfanzi
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1104 积分:8956 威望:0 精华:0 注册:2014/10/25 11:24:00
[建议][求助]关于横纵向打印,官方是不是给个最终的解决方案  发帖心情 Post By:2015/7/17 9:52:00 [只看该作者]

前二天测试打印用窗口做的入库单,用的是针打,用的是哪种二等分纸,即宽度241,高度139.7,打印预览中显示正常,但在预览中打印会方向反掉,最终我用的方案就是直接打印
今天在做窗口模式的合同时,用的是A4纸,横向打印的,直接打印会变成纵向,用预览中的打印又正常了,在直接打印的代码中,我用了这二种代码的各种组合,如:Doc.PageSetting.Landscape = True及doc.AutoRotate = False,但均告失败,打出来的死活是给向的。
虽然我可以取消直接打印代码用预览打印,但老是这么猜谜语一样的编代码,程序的执行结果不受控制实在让我揪心,打印是非常重要的功能,官方能好好的测试改善一下吗?
以下是我合同打印的代码:

_PrintForm.Page.LeftMargin = CDbl(e.Form.Controls("NumericComboBox1").text) '设置左边距
_PrintForm.Page.RightMargin = CDbl(e.Form.Controls("NumericComboBox2").text) '设置右边距
_PrintForm.Page.TopMargin = CDbl(e.Form.Controls("NumericComboBox3").text) '设置上边距
_PrintForm.Page.BottomMargin = CDbl(e.Form.Controls("NumericComboBox4").text) '设置下边距

_PrintForm.Page.Landscape = True '横向打印
Dim doc As PrintDoc = _PrintForm.GernatePrintDoc()

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
                For n As Integer =1 To t.Cols.Count - 1 '表的目录树占用了最左列导致实际列数从1开始,而不是0
                    If t.Cells(i,n).Text = Nothing AndAlso t.Cells(i,n+1).Text <> Nothing Then
                        t.Cells(i, 1).SpanCols = n
                        Exit For
                    End If
                Next
            End If
        Next
    End If
Next


Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = _CompanyName '调用在全局代码中设置的全局变量
rx.Cells(1,0).Text = _DocumentType '调用打开本窗口时赋值的全局变量
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 '作为页眉使用

doc.PageSetting.Width = CDbl(e.Form.Controls("NumericComboBox5").text)  '纸张宽度为XX毫米
doc.PageSetting.Height =  CDbl(e.Form.Controls("NumericComboBox6").text)  '纸张高度为XX毫米
doc.AutoRotate = False '禁止自动旋转打印内容

If e.Form.Controls("ComboBox_打印机").value = "" Then
Else
    Doc.PrinterName =e.Form.Controls("ComboBox_打印机").value
End If

'doc.Print
doc.Preview() '预览
[此贴子已经被作者于2015/7/17 9:52:08编辑过]

 回到顶部