Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Posted on 1999-07-30
Medium Priority
Last Modified: 2010-04-04
Hi, all. How can I print bitmap, and text?

Cheers, Zeko
Question by:zeko
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

RBertora earned 80 total points
ID: 1392004
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.


Author Comment

ID: 1392005

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question