DrawLine

DrawLine用于绘制直线,其语法为:

DrawLine(pen, x1, y1, float x2, float y2)

DrawLine(Pen pen, pt1, pt2)
 

参数 说明
pen 画笔
x1 直线起始水平位置
y1 直线起始垂直位置
x2 直线结束水平位置
y2 直线结束垂直位置
pt1 PointF类型,直线起始位置
pt2 PointF类型,直线结束位置

示例一

Dim file As String = "c:\temp\test.pdf"
Dim
pdc As New PDFCreator()
Dim
thinPen As New Pen(Color.Black, 1)
Dim
thickPen As New Pen(Color.Blue, 3)
Dim
dotPen As New Pen(Color.Red, 2)
dotPen.DashStyle = DashStyle.Dot
pdc.DrawLine(thinPen, 100, 100, 300, 100)
pdc.DrawLine(thickPen, 100, 120, 300, 120)
pdc.DrawLine(dotPen, 100, 140, 300, 140)

pdc.DrawLine(pens.Green, 100, 160, 300, 160)

pdc.Save(file)
pdc.Show()

绘制出的线条:

示例二

Dim file As String = "c:\temp\test.pdf"
Dim
margin As Integer = 72 '页边距
Dim
colsCount As Integer = 5 '列数
Dim
rowsCount As Integer = 5 '行数
Dim
colWidth As Integer = 93 '列宽
Dim
rowHeight As Integer = 30 '行高
Dim
pdc As New PDFCreator()
For
r As Integer = 0 To rowsCount
    pdc.DrawLine(pens.Red, margin, margin + r * rowHeight, margin + colsCount * colWidth, margin + r * rowHeight)

Next
For
c As Integer = 0 To colsCount
    pdc.DrawLine(pens.Red, margin + colWidth * c, margin, margin + colWidth * c, margin + rowsCount * rowHeight)

Next

pdc.DrawLine(pens.Red, margin, margin, margin + colWidth, margin + rowHeight)
pdc.Save(file)

pdc.Show()

执行后会生成一个表格:


本页地址:http://www.foxtable.com/webhelp/topics/6099.htm