Home/ Reference/ Layer & Shapes

layer.CreateRectangle2(x, y, w, h)

Draws a rectangle. (x, y) is the bottom-left corner; w and h are width and height. Units follow doc.Unit. This is what the code uses for full-page backgrounds and im

Signature

layer.CreateRectangle2(x, y, w, h)

Notes

Draws a rectangle. (x, y) is the bottom-left corner; w and h are width and height. Units follow doc.Unit. This is what the code uses for full-page backgrounds and image backplates.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
page  = doc.ActivePage
layer = page.ActiveLayer                 # every drawing method lives on layer

# CreateRectangle2(x, y, width, height): (x, y) is the BOTTOM-LEFT corner
W, H = 210 / 25.4, 297 / 25.4            # 210x297mm (document unit is inch here)
rect = layer.CreateRectangle2(0, 0, W, H)  # rect : the returned rectangle shape

rect.Outline.Width = 0                   # outline width 0 removes the outline
print("Page-sized rectangle drawn")

About this section: Layer & Shapes

Layer & Shapes — layers and shape creation.

Other entries in this section