Using VB.NET PDF SDK
VB.NET PDF Builder: How to draw, add a rectangle shape to PDF file
VB.NET Demo Code to create, draw, add a rectangle graph to pdf document
Draw rectangles on PDF context in vb.net
...
Dim ctx As PDFContext = New PDFContext()
' set figure size: width 600 pixels; height 100 pixels
ctx.SetWidth(New RELength(600, Units.PX))
ctx.SetHeight(New RELength(100, Units.PX))
' draw 2 rectangles
ctx.DrawRectangle(New REPen(New REColor(0, 255, 0)), 250, 10, 100, 80)
ctx.DrawRectangle(New REPen(New REColor(0, 255, 255), 3.0F), 200, 20, 300, 60)
Dim figure As Figure = New Figure(ctx)
document.Add(figure)
...
Add context to PDF document using vb.net
Dim outputFilePath As String = "C:\Sample25.pdf"
Dim document As Document = New Document()
PDFBuildHandler.Create(document, outputFilePath)
' open document
document.Open()
' create Figure
Dim ctx As PDFContext = New PDFContext()
...
...
Dim figure As Figure = New Figure(ctx)
document.Add(figure)
' close document and save to the output file
document.Close()
Let's see the result of adding a rectangle on PDF using vb.net: