ImageEn, unit iexPdfiumCore |
|
TPdfObjectList.AddRect
Declaration
function AddRect(X, Y, Width, Height: Single; DoInsert: Boolean = False; InsertIndex: Integer = 0): TPdfObject; overload;
function AddRect(X, Y, Width, Height: Single;
LineColor: TColor; LineWidth: Single = 1.0; LineOpacity: Single = 1.0;
Filled: boolean = false; FillColor: TColor = clBlack; FillOpacity: Single = 1.0;
DoInsert: Boolean = False; InsertIndex: Integer = 0): TPdfObject; overload;
Description
Add a rectangle object to the current page at the specified position (in terms of PDF points).
If DoInsert is enabled, the object will be inserted at the specified InsertIndex (i.e. its z-position is set, where 0 is the object closest to the page, and Count-1 is the front-most object).
Note: You must call
ApplyChanges before saving to apply object changes to the document
PDF Page Points
Objects on a PDF page are specified in points that originate at the bottom-left, i.e. when X,Y = (0,0). The top-left of the page is specified by (
PageWidth,
PageHeight).
To convert PDF points to screen values, use
PageToScr.
const
Rect_Width = 150;
Rect_Height = 100;
Rect_Color = clGreen;
Rect_Border = 3;
Rect_Fill = clYellow;
Rect_Opacity = 255;
var
obj: TPdfObject;
begin
obj := ImageEnView1.PdfViewer.Objects.AddRect( 100, 800, Rect_Width, Rect_Height );
obj.StrokeColor := TColor2TRGBA( Rect_Color, 255 );
obj.PathStrokeWidth := Rect_Border;
obj.FillColor := TColor2TRGBA( Rect_Fill, Rect_Opacity );
obj.PathFillMode := pfAlternate;
end;
// Insert a red rectangle at index 0, i.e. close to the background (below all other objects)
ImageEnView1.PdfViewer.Objects.AddRect( 100, 100, 200, 200, clNone, 0.0, 1.0, True, clRed, 1.0, True, 0 );