以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]专业报表套打  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=152746)

--  作者:冷泉
--  发布时间:2020/7/20 17:45:00
--  [求助]专业报表套打

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20200720173205.jpg
图片点击可在新窗口打开查看


图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20200720173840.jpg
图片点击可在新窗口打开查看


整体打印都会偏右,检查了一天不知道哪里错误,麻烦老师帮忙看看代码有没错误

譬如:我量了货物名称这里到左边距离大概是2.1CM  ,代码那里定位 X=21,但是实际打印却是偏右的

下面这个是代码:

Dim doc As New PrintDoc \'定义一个报表
Dim rx As prt.RenderText \'定义一个文本对象
Dim rm As prt.RenderImage \'定义一个图形队形
Dim CurRow As Row = Tables("物流单").Current

doc.PageSetting.Width = 212 \'纸张宽度为100毫米
doc.PageSetting.Height = 145 \'纸张高度为120毫米

doc.PageSetting.Landscape =False \'纵向打印
doc.AutoRotate = False \'禁止自动旋转打印内容

Doc.PageSetting.LeftMargin = 20 \'设置左边距
Doc.PageSetting.RightMargin = 20 \'设置右边距
Doc.PageSetting.TopMargin = 2 \'设置上边距
Doc.PageSetting.BottomMargin = 0 \'设置下边距


rx = new prt.RenderText
rx.Text = CurRow("发站")
rx.x = 97
rx.y = 20
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("到站")
rx.x = 130
rx.y = 20
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("托运人")
rx.x = 50
rx.y = 25
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("托运电话")
rx.x = 39
rx.y = 35
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("托运地址")
rx.x = 39
rx.y = 45  \'45.3
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("收货人")
rx.x = 128
rx.y = 25
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("收货电话")
rx.x = 117
rx.y = 35
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("收货地址")
rx.x = 117
rx.y = 45  \'45.3
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("货物名称1")
rx.x = 21   \'5
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("件数1")
rx.x = 57   \'+5
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("重量1")
rx.x = 70
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("体积1")
rx.x = 87
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("包装1")
rx.x = 105
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("运费1")
rx.x = 121
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("送货单1")
rx.x = 139  \'112
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("回单1")
rx.x = 155
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("货物名称2")
rx.x = 21  \'5
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("件数2")
rx.x = 52   \'+5
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("重量2")
rx.x = 70
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("体积2")
rx.x = 87
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("包装2")
rx.x = 105
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("运费2")
rx.x = 121
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("送货单2")
rx.x = 139 \'112
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("回单2")
rx.x = 155
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("特约事项1")
rx.x = 185 \'156
rx.y = 60 \'60
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("特约事项2")
rx.x = 185 \'156
rx.y = 66
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("现付")
rx.x = 45
rx.y = 75
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("到付")
rx.x = 69
rx.y = 75
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("月结")
rx.x = 94
rx.y = 75
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("回付")
rx.x = 122
rx.y = 75
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("货到打卡")
rx.x = 150
rx.y = 75
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("代收货款")
rx.x = 138
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("备注")
rx.x = 160
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = CurRow("代收")
rx.x = 160
rx.y = 88 \'+2
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = e.Form.Controls("Label1").text
rx.x = 55 \'+2
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = e.Form.Controls("Label2").text
rx.x = 72
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = e.Form.Controls("Label3").text
rx.x = 88
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = e.Form.Controls("Label4").text
rx.x = 100
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

rx = new prt.RenderText
rx.Text = e.Form.Controls("Label5").text
rx.x = 115
rx.y = 83 \'84.8
doc.body.Children.Add(rx)

Doc.Print() \'打印报表



--  作者:程兴刚
--  发布时间:2020/7/20 17:58:00
--  
不要月.x和.y,用.left和.top让左边距生效,以后调整左边距和上边距即可随意调整了!
--  作者:冷泉
--  发布时间:2020/7/20 18:04:00
--  
rx = new prt.RenderText
rx.Text = e.Form.Controls("Label5").text
rx.left = 115
rx.top = 83 \'84.8
doc.body.Children.Add(rx)

这样来设置?

提示错误:

left 不是C1.C1preview.RenderText 的成员
错误代码: rx.left = 115
[此贴子已经被作者于2020/7/20 18:08:19编辑过]

--  作者:程兴刚
--  发布时间:2020/7/20 22:57:00
--  
加入容器,采用对容器的left和top的值来进行设置实现对对象的定位!
--  作者:程兴刚
--  发布时间:2020/7/21 10:07:00
--  
精确定位用表格更方便(见打印按钮):

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:套打.foxdb