我实现标签打印的代码如下
但是现在发现一个问题 标签打出来是旋转了90度的 和我预想的不一样 代码改了很久一点作用也没有 请教高手
"条码"
Dim doc As New PrintDoc
doc.PageSetting.Width = 60
doc.PageSetting.Height = 40
Doc.PageSetting.LeftMargin = 1
Doc.PageSetting.TopMargin = 1
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
Dim i As Integer=Tables("打印选择").Rows.count-1
For i=0 To i
Dim t As Integer=Tables("打印选择").Rows(i)("打印张数")
If t>0 Then
For t=1 To t
Dim ra As New prt.RenderArea
Dim rt As prt.RenderText
ra.Width = 58
ra.Height =38
ra.Style.Spacing.All = 1
ra.Style.Borders.All = New prt.Linedef(0.3, Color.black)
ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never
Doc.Body.ChildRen.Add(ra)
rt = New prt.RenderText
rt.Text = "名称: "
rt.X =4
rt.Y = 2
rt.Style.Font = New Font("宋体",14)
ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text = Tables("打印选择").Rows(i)("药材名称")
rt.X =20
rt.Y = 2
rt.Style.Font = New Font("宋体",12)
ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text = "单位: "
rt.X =4
rt.Y = "Prev.Bottom + 2"
rt.Style.Font = New Font("宋体", 14)
ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text = Tables("打印选择").rows(i)("单位")
rt.X =20
rt.Y = "Prev.Top"
rt.Style.Font = New Font("宋体",12)
ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text = "SN: "
rt.X =4
rt.Y = "Prev.Bottom + 2"
rt.Style.Font = New Font("宋体", 14)
ra.Children.Add(rt)
rt = New prt.RenderText
rt.Text =Tables("打印选择").rows(i)("SN")
rt.X =20
rt.Y = "Prev.Top"
rt.Style.Font = New Font("宋体",12)
ra.Children.Add(rt)
Dim rpar As New prt.RenderParagraph()
Dim img As prt.RenderImage
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.Code39
Bar.BarRatio = 0.3
Bar.BarHeight = 8
Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
If not Tables("打印选择").rows(i).Isnull("SN") Then
bar.Code = Tables("打印选择").rows(i)("条码")
img = new prt.RenderImage
img.Image = bar.GetImage
Dim rm As New prt.RenderImage '定义一个图片对象
rm.Image =bar.getimage '设置图片
rm.Width = "Parent.Width" '宽度等于页面宽度
rm.Height = "Auto" '高度由图片大小自动决定
rm.Style.ImageAlign.StretchHorz = False '禁止图片水平拉伸
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center
rm.X=2
rm.y="Prev.Bottom + 2"
ra.Children.Add(rm)
Tables("打印选择").rows(i)("已打印")=True
Else
messagebox.show("请输入" &Tables("打印选择").rows(i)("药材名称") &"的SN码!")
Return
End If
Next
Else
messagebox.show("请输入" &Tables("打印选择").rows(i)("药材名称") &"的打印张数!")
Return
End If
Next
Doc.Preview()