Hi, all. How can I print bitmap, and text?

Cheers, Zeko
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Straight from the delphi help:

To print the contents of a memo component,

1.      Assign a text-file variable to the printer by calling AssignPrn.
2.      Create and open the output file by calling Rewrite.
      Any Write or Writeln statements sent to the file variable are then written on the Canvas of the printer object.

The AssignPrn procedure is declared in the Delphi Printers unit, so you must add Printers to the uses clause of the unit that calls AssignPrn.

When the printer is ready for input, you can write the contents (Lines property) of the memo to the printer.


The following example prints the contents of a Memo field when the user chooses File|Print.

procedure TForm1.Print1Click(Sender: TObject);
  Line: Integer;
  PrintText: TextFile;   {declares a file variable}
  if PrintDialog1.Execute then
    AssignPrn(PrintText);   {assigns PrintText to the printer}
    Rewrite(PrintText);     {creates and opens the output file}
    Printer.Canvas.Font := Memo1.Font;  {assigns Font settings to the canvas}
    for Line := 0 to Memo1.Lines.Count - 1 do

      Writeln(PrintText, Memo1.Lines[Line]);      {writes the contents of the Memo1 to the printer object}
    CloseFile(PrintText); {Closes the printer variable}

Printing graphic images from a Delphi application is a simple task. The only requirement for printing is that you add the Printers unit to the uses clause of the form that will call the printer. The Printers unit declares a printer object called Printer that has a canvas that represents the printed page.

To print a graphic image,

Copy the image to the printer's canvas.


The following code copies the image of a form to the printer in response to a click on a button named PrintButton:

procedure TForm1.PrintButtonClick(Sender: TObject);
  with Printer do
    BeginDoc;      { start printing }
    Canvas.Draw(0, 0, Image);      { draw Image at top left corner of printed page }
    EndDoc;      { finish printing }

You can use the printer's canvas just as you would any other canvas. In particular, that means you can copy the contents of a graphic object, such as a bitmap, to the printer directly.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zekoAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.