'Functions.Execute("专业报表打印1","D:\蒋安\蒋安个人资料\督导组财务\ddzcw2020\ddzcw\images")
Dim f As String = args(0)
Dim Files As object = FileSys.GetFiles(args(0)) '("D:\蒋安\蒋安个人资料\督导组财务\ddzcw2020\ddzcw\image")
For i As Integer = 0 To Files.count - 1 Step 2
Dim doc As New PrintDoc '定义一个报表
Doc.PageSetting.LeftMargin = 20 '设置左边距
Doc.PageSetting.RightMargin = 20 '设置右边距
Doc.PageSetting.TopMargin = 15
Dim f1 As String = Files(i)
Dim bmp As bitmap
Dim bmp2 As bitmap
'====定义文本对象======
Dim rs As New prt.RenderText '定义一个文本对象
rs.Text = "龙台片区督导组出差凭证(截图)" '设置文本对象的内容
rs.Style.TextColor = Color.Red '字符颜色设为红色
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rs.Style.Font = New Font("宋体", 20,FontStyle.Bold) ''字符大小及类别
rs.Style.Spacing.Bottom = 3 '以象之间的间距
doc.Body.Children.Add(rs)
'====定义表格对象======
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rm As New prt.RenderImage() '定义一个图片对象
Dim img As Image = GetImage(f1)
If img.Height >img.Width Then
img.RotateFlip(system.drawing.RotateFlipType.Rotate270FlipNone)
End If
If img.Height> 265 Then
bmp = new bitmap(img, img.width*(265/img.height),265)
rm.image = bmp
Else
rm.image = img
End If
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
rm.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片
rm.Style.ImageAlign.StretchVert = False '禁止垂直方向扩展图片
rm.Width = 170
rm.Height = 70
doc.Body.Children.Add(rt) '将表格对象加入到报表中
rt.Style.GridLines.All = New prt.Linedef(Color.DarkGray) '将表格的颜色设为深灰色
rt.Rows.Count = 0 '设置行数
rt.Cols.Count = 0 '设置列数
rt.Width = 170 '设置表格的宽度
rt.Height = 70'设置表格的高度
rt.Cells(0,0).RenderObject = rm '将单元格内容设置为图片对象rm
'====定义文本对象2======
Dim rs2 As New prt.RenderText '定义一个文本对象
rs2.Text = "报账人:蒋安" '设置文本对象的内容
rs2.Style.TextColor = Color.Red '字符颜色设为红色
rs2.Style.TextAlignHorz = prt.AlignHorzEnum.right '水平居中
rs2.Style.Font = New Font("宋体",10 , FontStyle.Bold) '
rs2.Style.Spacing.Top = 3
rs2.Style.Spacing.Bottom = 5 '定义两个报表之间的距离
doc.Body.Children.Add(rs2)
'=====定义中间的分隔线======
Dim rsx As New prt.RenderText '定义一个文本对象
rsx.Text = "- - - - - - - - - - - - - - - - - - - - - - - - -" '设置文本对象的内容
rsx.Style.TextColor = Color.Green '字符颜色设为红色
rsx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rsx.Style.Font = New Font("宋体", 5, FontStyle.Bold) ''字符大小及类别
rsx.Style.Spacing.Bottom = 10 '以象之间的间距
doc.Body.Children.Add(rsx)
f1 = files(i+1)
Dim rs3 As New prt.RenderText '定义一个文本对象
rs3.Text = "龙台片区督导组出差凭证(截图)" '设置文本对象的内容
rs3.Style.TextColor = Color.Red '字符颜色设为红色
rs3.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rs3.Style.Font = New Font("宋体", 20, FontStyle.Bold) ''字符大小及类别
rs3.Style.Spacing.Top = 5
rs3.Style.Spacing.Bottom = 3 '以象之间的间距
doc.Body.Children.Add(rs3)
'====定义表格对象======
Dim rt2 As New prt.RenderTable() '定义一个表格对象
Dim rm2 As New prt.RenderImage() '定义一个图片对象
Dim img2 As image= GetImage(f1)
If img2.Height >img2.Width Then
img2.RotateFlip(system.drawing.RotateFlipType.Rotate270FlipNone)
End If
If img2.Height> 265 Then
bmp2 = new bitmap(img2, img2.width*(265/img2.height),265)
rm2.Image = bmp2
Else
rm2.Image = img2
End If
rm2.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
rm2.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
rm2.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片
rm2.Style.ImageAlign.StretchVert = False '禁止垂直方向扩展图片
rm2.Width = 170
rm2.Height = 70
doc.Body.Children.Add(rt2) '将表格对象加入到报表中
rt2.Style.GridLines.All = New prt.Linedef(Color.DarkGray) '将表格的颜色设为深灰色
rt2.Rows.Count = 0 '设置行数
rt2.Cols.Count = 0 '设置列数
rt2.Width = 170 '设置表格的宽度
rt2.Height = 70'设7表格的高度
rt2.Cells(0,0).RenderObject = rm2 '将单元格内容设置为图片对象rm
'====定义文本对象2======
Dim rs4 As New prt.RenderText '定义一个文本对象
rs4.Text = "报账人:蒋安" '设置文本对象的内容
rs4.Style.TextColor = Color.Red '字符颜色设为红色
rs4.Style.TextAlignHorz = prt.AlignHorzEnum.right '水平居中
rs4.Style.Font = New Font("宋体",10 , FontStyle.Bold) '
rs4.Style.Spacing.Top = 3
doc.Body.Children.Add(rs4)
Doc.Preview() '预览报表
Next
后来改成自主多选进行打印,参数传递出错
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
Functions.Execute("专业报表打印1",dlg.FileNames)
End If
函数中遍历的是文件夹,多选框架返回的是一个字符数组,如何改?