Print a frame line around the text area

<< Click to Display Table of Contents >>

Navigation:  Programming > Printing and PDF Export > Watermarks >

Print a frame line around the text area

Print a frame line around the text area

 

(1) We are using the main page layout information:

 

procedure TWaterM.WPRichText1PaintWatermark(Sender: TObject;

  RTFEngine: TWPRTFEnginePaint; toCanvas: TCanvas;

  PageRect: TRect; PaintPageNr, RTFPageNr: Integer; WaterMarkRef: TObject;

  XRes, YRes: Integer;

  FCurrentZoom : Single;

  PaintMode: TWPPaintModes);

var r: TRect;

begin

 r.Left := PageRect.Left + MulDiv( RTFEngine.RTFData.Header.LeftMargin, XRes, 1440);

 r.Top := PageRect.Top + MulDiv( RTFEngine.RTFData.Header.TopMargin, YRes, 1440);

 r.Right := PageRect.Right - MulDiv( RTFEngine.RTFData.Header.RightMargin, XRes, 1440);  

 r.Bottom := PageRect.Bottom - MulDiv( RTFEngine.RTFData.Header.BottomMargin, YRes, 1440);

 toCanvas.Pen.Color := clBtnShadow;

 toCanvas.Pen.Width := 0;

 toCanvas.Brush.Style := bsClear;

 toCanvas.Rectangle(r);

end;

 

 

(2) Now we are using the page layout information for the current page.

 

if RTFPageNr > 0 then

begin

   r.Left := PageRect.Left + MulDiv(

        RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginLeft, XRes, 1440);

   r.Top := PageRect.Top + MulDiv(

        RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginTop, YRes, 1440);

   r.Right := PageRect.Right - MulDiv(

        RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginRight, XRes, 1440);

   r.Bottom := PageRect.Bottom - MulDiv(

        RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginBottom, YRes, 1440);

   toCanvas.Pen.Color := clBtnShadow;

   toCanvas.Pen.Width := 0;

   toCanvas.Brush.Style := bsClear;

   toCanvas.Rectangle(r);

end;

 

Please note that the parameter RTFPageNr  can be 0 if the page was inserted as "external page".