以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教要打印二维码和文字怎么弄  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=121702)

--  作者:yuweijie
--  发布时间:2018/7/11 19:46:00
--  请教要打印二维码和文字怎么弄


图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看
如上图,要怎么编程?我用的是12mm宽的条码打印机。

 

Dim doc As New PrintDoc
Dim rg As prt.RenderGraphics
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.QRCode
Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
For Each r As Row In Tables("灭火器表").Rows
    bar.Code = r("编码")
    rg = new prt.RenderGraphics
    bar.DrawOnCanvas(rg.Graphics,0,0,1)
    rg.Style.Spacing.All = 3
    Doc.Body.Children.Add(rg)
Next
Doc.Preview()


--  作者:有点甜
--  发布时间:2018/7/11 21:44:00
--  

1、设置好纸张不就好了?

 

http://www.foxtable.com/webhelp/scr/2904.htm

 

2、你想设置条码的大小?

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=117728&skin=0

 

 

 

 

 


--  作者:yuweijie
--  发布时间:2018/7/14 12:43:00
--  
Dim doc As New PrintDoc() \'定义一个报表
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx As prt.RenderText \'定义一个文本对象
Dim rg As prt.RenderGraphics
Dim Bar As New BarCodeBuilder
Dim j As Integer = 0 \'用于调整偏移
Dim r As Row
Dim tbl As Table = Tables("灭火器表")
For i As Integer = tbl.TopRow To tbl.BottomRow
    r = tbl.rows(i)
    Dim rep As New prt.RenderEmpty \'定义一个新的空对象
    rep.BreakBefore = prt.BreakEnum.Page \'打印前换页
    doc.Body.Children.Add(rep ) \'加入到报表中
    \'设置纸张页面
    doc.PageSetting.Width = 80 \'纸张宽度为100毫米
    doc.PageSetting.Height = 24 \'纸张高度为120毫米
    Doc.PageSetting.LeftMargin = 1 \'设置左边距
    Doc.PageSetting.RightMargin = 1 \'设置右边距
    Doc.PageSetting.TopMargin = 1 \'设置上边距
    Doc.PageSetting.BottomMargin = 1 \'设置下边距
    
    \'设置表格
    doc.Body.Children.Add(rt) \'将表格对象加入到报表中
    rt.Style.GridLines.All = New prt.LineDef \'将网格线类型设为默认类型
    rt.Width = "Auto"
    rt.Rows(0).Height = 6.8 +j \'设置行高
    rt.Cols(0).Width = 23 + j \'设置列宽
    rt.Rows(1).Height = 6.8 +j \'设置行高
    rt.Cols(1).Width = 27 + j \'设置列宽
    rt.Rows(2).Height = 6.9+j \'设置行高
    rt.Cols(2).Width = 27 + j \'设置列宽
    rt.Cells(0,0).SpanRows = 3 \'向下合并三行
    rt.cells(0,1).SpanCols = 2
    rt.cells(1,1).SpanCols = 2
    rt.cells(2,1).SpanCols = 2
    \'设置二维码
    Bar.Symbology = Barpro.Symbology.QRCode
    \'Doc.Stacking = prt.StackingRulesEnum.BlockLeftToRight
    bar.Code = r("编码")
    rg = new prt.RenderGraphics
    bar.DrawOnCanvas(rg.Graphics,0,0,1)
    \'rg.Style.Spacing.All = 3
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中Spacing
    rt.Cells(0,0).RenderObject = rg
    rt.Cells(0,1).Text = " 设备编码:  " & r("编码")
    rt.Cells(1,1).Text = " 放置地点:  " & r("放置地点")
    rt.Cells(2,1).Text = " 管理员    :  " & r("管理员")
Next
Doc.Preview() \'预览报表



上面代码,如果选一行打印没问题,框选两行就会出错,错误提示 为:“添加的项目已经有所有者了。”请教问题出在哪里了?

--  作者:有点蓝
--  发布时间:2018/7/14 14:12:00
--  
……
rt = New prt.RenderTable()
\'设置表格
    doc.Body.Children.Add(rt) \'将表格对象加入到报表中
    rt.Style.GridLines.All = New prt.LineDef \'将网格线类型设为默认类型
    rt.Width = "Auto"
……

--  作者:yuweijie
--  发布时间:2018/7/14 20:35:00
--  
谢谢,已经可以了。