Watermark
The code below is from your sample.
How can I have Watermark aligned at right?
Aligned left is easy Aligned right???
-----------------------------------------------------------------------
Company name phone
Address e_mail
I change Top and Left to 0 (zero) and works fine
lWaterMark.Top := 0;//;(llPageHeight - lWaterMark.Height) div 2;
lWaterMark.Left := 0;// llPageWidth - lWaterMark.Width ) div 2;
Thanks
Sergio
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.Print;
end;
procedure TForm1.ppReport1EndPage(Sender: TObject);
begin
CreateWaterMark.Page := ppReport1.Engine.Page;
end;
function TForm1.CreateWaterMark: TppDrawCommand;
var
lWaterMark: TppDrawText;
llPageHeight: Longint;
llPageWidth: Longint;
liTextWidth: Integer;
liTextHeight: Integer;
lPrinter: TppPrinter;
begin
lWaterMark := TppDrawText.Create(nil);
lWaterMark.TextAlignment:= taLeftJustified;
lWaterMark.WrappedText.Add('ReportBuilder ' + ppEdition + #153 + ' -
Demo Copy');
lWaterMark.WrappedText.Add('Version ' + ppVersion);
lWaterMark.WrappedText.Add('Digital Metaphors Corporation');
lWaterMark.WrappedText.Add('Telephone: 303.531.8032');
lWaterMark.WrappedText.Add('E-Mail: sales@digital-metaphors.com');
lWaterMark.Transparent := True;
lWaterMark.IsMemo := False;
lWaterMark.WordWrap := True;
lWaterMark.Font.Name := 'Arial';
lWaterMark.Font.Size := 18;
lWaterMark.Font.Color := clBlack;
lWaterMark.Autosize := True;
liTextWidth := 375;
liTextHeight := 150;
lPrinter := ppReport1.Printer;
llPageHeight := lPrinter.PrinterSetup.PageDef.mmPrintableHeight;
llPageWidth := lPrinter.PrinterSetup.PageDef.mmPrintableWidth;
lWaterMark.Height := ppToMMThousandths(liTextHeight, utScreenPixels,
pprtHorizontal, nil);
lWaterMark.Width := ppToMMThousandths(liTextWidth, utScreenPixels,
pprtHorizontal, nil);
lWaterMark.Top := 0;//;(llPageHeight - lWaterMark.Height) div 2;
lWaterMark.Left := 0;// llPageWidth - lWaterMark.Width ) div 2;
Result := lWaterMark;
end;
--
How can I have Watermark aligned at right?
Aligned left is easy Aligned right???
-----------------------------------------------------------------------
Company name phone
Address e_mail
I change Top and Left to 0 (zero) and works fine
lWaterMark.Top := 0;//;(llPageHeight - lWaterMark.Height) div 2;
lWaterMark.Left := 0;// llPageWidth - lWaterMark.Width ) div 2;
Thanks
Sergio
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.Print;
end;
procedure TForm1.ppReport1EndPage(Sender: TObject);
begin
CreateWaterMark.Page := ppReport1.Engine.Page;
end;
function TForm1.CreateWaterMark: TppDrawCommand;
var
lWaterMark: TppDrawText;
llPageHeight: Longint;
llPageWidth: Longint;
liTextWidth: Integer;
liTextHeight: Integer;
lPrinter: TppPrinter;
begin
lWaterMark := TppDrawText.Create(nil);
lWaterMark.TextAlignment:= taLeftJustified;
lWaterMark.WrappedText.Add('ReportBuilder ' + ppEdition + #153 + ' -
Demo Copy');
lWaterMark.WrappedText.Add('Version ' + ppVersion);
lWaterMark.WrappedText.Add('Digital Metaphors Corporation');
lWaterMark.WrappedText.Add('Telephone: 303.531.8032');
lWaterMark.WrappedText.Add('E-Mail: sales@digital-metaphors.com');
lWaterMark.Transparent := True;
lWaterMark.IsMemo := False;
lWaterMark.WordWrap := True;
lWaterMark.Font.Name := 'Arial';
lWaterMark.Font.Size := 18;
lWaterMark.Font.Color := clBlack;
lWaterMark.Autosize := True;
liTextWidth := 375;
liTextHeight := 150;
lPrinter := ppReport1.Printer;
llPageHeight := lPrinter.PrinterSetup.PageDef.mmPrintableHeight;
llPageWidth := lPrinter.PrinterSetup.PageDef.mmPrintableWidth;
lWaterMark.Height := ppToMMThousandths(liTextHeight, utScreenPixels,
pprtHorizontal, nil);
lWaterMark.Width := ppToMMThousandths(liTextWidth, utScreenPixels,
pprtHorizontal, nil);
lWaterMark.Top := 0;//;(llPageHeight - lWaterMark.Height) div 2;
lWaterMark.Left := 0;// llPageWidth - lWaterMark.Width ) div 2;
Result := lWaterMark;
end;
--
This discussion has been closed.
Comments
The code in the example places the drawcommand in the center of the page
vertically and horizontally.
lWaterMark.Top := (llPageHeight - lWaterMark.Height) div 2;
lWaterMark.Left := (llPageWidth - lWaterMark.Width ) div 2;
To place the drawcommand at the top right, you would do something like
the following...
lWaterMark.Top := 0;
lWaterMark.Left := llPageWidth - lWaterMark.Width;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com