Lines & Rectangles

PDFReports also allows you to draw vectors: this simple code shows you how.

Let's start from the syntax of the DrawLine method.

PDFRPT.DrawLine Width, Left, Right, Top, Bottom
  • Width: Width of the line in pixels, integer
  • Top: distance from the Top border of the page, double
  • Left: distance from the Left border of the page, double
  • Right: distance from the Right border of the page, double
  • Bottom: distance from the Bottom border of the page, double

All distances are expressed in the current unit of measure (see previous chapter).

Here's the syntax of the DrawRect method.

PDFRPT.DrawRect Width, blnFill, blnOutline, Left, RectWidth, Top, RectHeight
  • Width: Width of the line in pixels, Long
  • blnFill: set = 0 for no Fill, set = 1 for filling with current color the rectangle, Long
  • blnOutline: 0 = no border, 1 = border visible, Long
  • Top: distance from the Top border of the page, double
  • Left: distance from the Left border of the page, double
  • RectWidth: Width of the rectangle, double
  • Top: distance from the Top border of the page, double
  • RectHeight: Height of the rectangle

 

Here's some sample code and the resulting PDF:

Private Sub Command5_Click()
  Dim PDFRPT As New PDFDocument
  PDFRPT.NewPDF "This is my first PDF"
  PDFRPT.DrawLine 1, 10, 40, 20, 60
  PDFRPT.DrawRect 2, 0, 1, 20, 30, 20, 40  
  PDFRPT.SavePDF "c:\provaocx.pdf"
End Sub