PdfRectangle(x as double, y as double, w as double, h as double, FillMode as String) As Boolean

 

Draw a rectangle.

 

 

If the coordinate system is bottom-up, the point X, Y defines the lower left corner of the bounding rectangle.

If the coordinate system is top-down it defines the upper left corner.

 

 

Parameters:

 

Name

Type

Description

x

Double

Position from Left in points

y

Double

Position from Top in points (If PdfSetPageCoordsTopDown is set)

Position from Bottom in points (If PdfSetPageCoordsBottomUp is set)

w

Double

Width of rectangle in points

h

Double

Height of rectangle in points

FillMode

String

 

STROKE

draws frame of rectangle with color set by PdfSetStrokeColor

FILL

fills contents of rectangle with color set by PdfSetFillColor

FILLSTROKE

draws frame and fills contents with colors set by PdfSetStrokeColor for frame and PdfSetFillColor for contens.

 

 

 

Returns:

 

Type

Value

Description

Integer

-1 or higher

Returns 0 or higher if the rectangle has been drawn to a pdf page.

Returns -1 upon failure

 

Available in:

 

WindowMain

WindowLink

YES

YES

 

Hint: You can find references to XojoScripts which make use of this function by sending the following SQL statement to the database:

Select id,GUID, ScriptName,ScriptCode from im_scripts where ScriptCode Like '%PdfRectangle%'

 

Example XojoScript:

 

If PdfStart("testfile.pdf") > 0 Then

 

// Set top top-left as 0,0 coordinates

PdfSetPageCoordsTopDown

Dim x,y As Double = 30.0

 

// Set output font and color

PdfSetFont("Arial","Regular",10.0)

Call PdfSetFillColor("&c00000000") // black textcolor

 

// write a location and current date

Call PdfWriteText(x,y,"Page 1")

 

// Set fill color of rectangle

Call PdfSetFillColor("&cF3BC1900") // yellow

 

// Set frame color of rectangle

Call PdfSetStrokeColor("&c3F7DFFFF") // blue

 

// Fill the rectangle

Call PdfRectangle(x,60.0,300.0,50.0,"FILLSTROKE")

 

// Finalize PDF

Call PdfcloseFile

 

// Open PDF in default viewer

Call Pdflaunch

 

End If