Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Delphi print

delphi

  • Please log in to reply
2 replies to this topic

#1 Henryk555

Henryk555

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 01 March 2012 - 08:03 AM

Hi,
How to print a text from a file or from memo, richedit to add frame around ?:sneaky:
  • 1

#2 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 01 March 2012 - 09:58 AM

What have you done so far?
  • 0

#3 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 05 March 2012 - 10:06 AM

To print simple text, you can use codes like this:

uses
  ...
  , Printers
  ...
  ;

procedure PrintText(ATexts: TStrings);
var
  i: Integer;
  vText: string;
  vTop, vLeft: Integer;
begin
   Printer.BeginDoc;
   vTop := TOP_MARGIN;
   vLeft := LEFT_MARGIN;

   for i := 0 to ATexts.Count-1 do
   begin
     vText := ATexts[i];
     Printer.Canvas.TextOut(vLeft, vTop, vText);
     vTop := vTop + Printer.Canvas.TextHeight(vText) + MARGIN_BETWEEN_LINE;
   end;
   Printer.EndDoc;  // this is where the print job actually begins
end;

For adding frame, making stylish characters (bold, italic, etc.) you have to play around with Printer.Canvas.

Note: the above code is using default printer.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download