Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Watermarks using TPrinter 2

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I googled TPrinter Watermark looking for a way to directly send a watermark command to the printer, but all I can find is addins that have the following bit of information:

methods like Delphi's TPrinter but is designed to generate a PDF file. ...

I'm not interested in creating PDFs. We have an interview that I am currently changing from a Lotus Notes application to a Delphi application. The Lotus Notes program uses an excel spreadsheet to fill in specific pieces of information into a template and if certain pieces of information are on the spreadsheet, conditional watermarks are applied. For instance, if the interview contains information regarding treatment or medication, 'CONFIDENTIAL' is watermarked across the interview, if the defendant was ROR, then that appears on the interview, etc.

Does anyone know of a way to add a watermark to a TPrinter command?

I considered creating a transparent image to place over the print out, think that would work?

thanks for any input!

leslie
 
I printed a watermark myself by specifying a large font (60 points or so), a light grey color, and in an angle from down left to upper right corner of the paper, then printing something like 'Watermark' or the company name, or 'FOR INTERNAL USE ONLY' etc. After this, the normal output is printed from top left to bottom right...

HTH
TonHu
 
do you have a code sample of the angled printout?

thanks!

leslie
 
Try this in a normal form.

Code:
procedure DrawRotated(Canvas : TCanvas;
                      x, y   : integer;
                      Angle  : integer;
                      Txt : AnsiString);
var
  lf : TLogFont;
  tf : TFont;
  bf : TFont;      // buffer
begin
  {Save actual.}
  bf := TFont.Create;
  bf.Assign(Canvas.Font);
  {Change canvas font type and size.}
  Canvas.Font.Name := 'Modern';
  Canvas.Font.Size := 24;
  {Create new and rotate.}
  tf := TFont.Create;
  tf.Assign(Canvas.Font);
  GetObject(tf.Handle, sizeof(lf), @lf);
  lf.lfEscapement := Angle * 10;
  lf.lfOrientation := Angle * 10;
  tf.Handle := CreateFontIndirect(lf);
  Canvas.Font.Assign(tf);
  {Free and write.}
  tf.Free;
  Canvas.TextOut(x, y, Txt);
  {Restore original and free buffer.}
  Canvas.Font.Assign(bf);
  bf.Free;
end;

procedure TForm1.btnWriteClick(Sender: TObject);
  begin
    DrawRotated(Canvas, 100, 200, 90, 'Rotated 90');
    DrawRotated(Canvas, 100, 200, 45, 'Rotated 45');
    DrawRotated(Canvas, 100, 200, 0, 'Rotated 0');
    DrawRotated(Canvas, 100, 200, -45, 'Rotated -45');
    DrawRotated(Canvas, 100, 200, -90, 'Rotated -90');
    Canvas.TextOut(20, 40, 'Normal');
  end;

Written on the fly, please check to be sure you are not leaking GDI handles.

buho (A).

 
thanks! I'll give this a try this morning and post back with any questions.

Les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top