Printing Text with a Shaded Background

Printing Text with a Shaded Background

Post by Steve Argen » Thu, 24 Oct 2002 18:55:18



I'm writing an application that prints numerous types of reports.  In some
cases, in the routine that prints the report, I need to shade a rectangular
area behind some text that's already been printed using Canvas.Textout.
I've tried several different styles and modes for the Pen and Brush but
every time, when I use the FillRect procedure to create the shaded area, the
text that was underneath the shaded area is no longer visible on the
printout.  Is there some particular combination of styles and modes that
will allow that shaded area to be drawn and still allow previously output
text to show through?  Thanks in advance for any help...

Steve

 
 
 

Printing Text with a Shaded Background

Post by Gary William » Thu, 24 Oct 2002 22:19:49



> I've tried several different styles and modes for the Pen and Brush but
> every time, when I use the FillRect procedure to create the shaded area,
the
> text that was underneath the shaded area is no longer visible on the
> printout.

You must plot the text _after_ calling FillRect.

-Gary

 
 
 

Printing Text with a Shaded Background

Post by Steve Argen » Thu, 24 Oct 2002 23:12:35


Gary, thanks for the quick response.  Actually after a few hours effort, I
ended up answering my own question and finally figured out how to create a
shaded area over previously written text using the Rectangle procedure.  Any
previously written text or previously drawn lines will show through the
newly shaded area.  The following illustrates how I accomplished this:

Procedure ShadeArea(x1, y1, x2, y2: Integer; ShadeColor: TColor);
var
   x, y: Integer;
   old_x, old_y: Integer;
begin
   with Printer.Canvas do begin
      // save current printer position
      old_x:=PenPos.X;
      old_y:=PenPos.Y;
      // shade the requested cell
      Pen.Width:=1;
      Pen.Style:=psClear;
      Pen.Mode:=pmNotXor;
      Brush.Style:=bsSolid;
      Brush.Color:=ShadeColor;
      Rectangle(x1, y1, x2, y2);
      // restore the previous settings
      Pen.Style:=psSolid;
      Pen.Mode:=pmCopy;
      Brush.Style:=bsClear;
      MoveTo(old_x, old_y);
   end;
end;



> > I've tried several different styles and modes for the Pen and Brush but
> > every time, when I use the FillRect procedure to create the shaded area,
> the
> > text that was underneath the shaded area is no longer visible on the
> > printout.

> You must plot the text _after_ calling FillRect.

> -Gary

 
 
 

1. Printing PCL text on grey background

During print using Printer object after setting PaperBin
property following error occurs:

Text printed in black on gray rectangle is printed with
extra white background. In other words, text is placed in
white rectangle placed on gray background.
The error does not occur when the paper bin is not changed.
It happens for various PCL drivers.

Please help.

2. Axis object in POV

3. Print text on gray background on HP laser printer

4. 24bit and 8 bit at once

5. 3d text and shaded text

6. ?--stroboscopic, psychedelic dummy objects--?

7. Placing graphics on a shaded background

8. How to remove many shades of background

9. visible text on shaded area

10. Shaded text

11. Shading Text