<< Click to Display Table of Contents >> Navigation: Programming > Printing and PDF Export > Add PDF Export > Detect rectangles for subsequent signing |
We recommend to create a merge field and inside the merge field an image as a placeholder.
Using the OnTextObjectPaint event ist is possible to know the position and page number:
procedure TForm1.WPRichText1TextObjectPaint(Sender: TObject;
pobj: TWPTextObj; toCanvas: TCanvas; XRes, YRes, X, Y, W, H, BASE: Integer;
PageRef: TWPVirtPage; Modes: TWPTextObjectPaintModes;
const CanvasExtraAttr: TWPPaintExtraParams;
var ContinueMode: TWPTextObjectPaintResult);
var currfield : TWPTextObj;
pos_in_pt : TRect;
begin
currfield := WPRichText1.CodeInsideOf(
pobj.ParentPar, pobj.ParentPosInPar, wpobjMergeField
);
if currfield<>nil then
begin
// check currfield.Name ...
// --> PageRef.PageNr
pos_in_pt := Rect(
MulDiv(x,72,XRes),
MulDiv(y,72,YRes),
MulDiv(x+w,72,XRes),
MulDiv(y+h,72,XRes)
);
// Store the rectangle for subsequent signing
// The page number is
//--> PageRef.PageNr
// Hide in PDF export
if wpPaintObjDestIsPDF in Modes then
ContinueMode := [];
end;
end;