使用ComboBox
增加ComboBox的参考代如下,可在命令窗口测试执行:
Dim
file
As
String
=
"c:\temp\test.pdf"
Dim
pdc
As
New
PDFCreator()
Dim
rect
As
RectangleF = pdc.PageRectangle
rect.Inflate( - 72, - 72)
'用于添加ComboBo的Lambda过程,tOffSet为文本框和标题的水平距离,tWidth为文本框宽度,tDefaultText为默认值
Dim
CreateComboBox =
Sub(tCaption
As
String,
tItems
As
String,
tFont
As
Font, tRect
As
RectangleF, tOffSet
As
Double,
tWidth
As
Double,
tDefaultText
As
String)
pdc.DrawString(tCaption &
":",
tFont, color.Black, tRect)
Dim
tRectBox
As
New
RectangleF(tRect.Left + tOffSet, tRect.Top - 3, tWidth, tFont.Size + 6)
Dim
tComboBox
As
New
PDF.PdfComboBox()
tComboBox.Font = tFont
tComboBox.BorderColor = Color.Azure
tComboBox.BorderWidth = PDF.FieldBorderWidth.Medium
For
Each
item
As
String
In
tItems.Split("|")
tComboBox.Items.Add(item)
Next
tComboBox.DefaultText = tDefaultText
pdc.AddField(tComboBox, tRectBox)
End
Sub
Dim
fnt
As
New
Font("微软雅黑",
12)
CreateComboBox.Invoke("学历",
"博士|硕士|本科|高中",
fnt, rect, 40, 120,
"硕士")
rect.Offset(0, 25)
CreateComboBox.Invoke("性别",
"男|女",
fnt, rect, 40, 120,
"女")
pdc.Save(file)
Process.Start(file)
生成的文档如下: