Printing across pages

TAdvStringgrid; RadStudio XE3

We wish to first print non-grid info on a page, then print a grid on the same page. the grid may extend to other pages.

TPrinter *printer = Printer();


...print info onto printer canvas, then:

grid->PrintRect(rect); fails because printing is in progress

if we do this:


grid->PrintRect(rect); this works, but the grid starts on another page

grid->PrintDrawRect(printer->Canvas, rect1, rect2); this works without first issuing EndDoc(), but does not print across page boundaries.

In previous grid versions, we fixed your code in PrintRect() to recognize printing in progress, but cannot do a code fix in this case.

How to accomplish our task?



Did you look at TAdvStringGrid sample application 9 that demonstrates the recommended way to handle this?

Re: the sample. We have some questions.

We assume the Canvas arg in the sample is the printer canvas?

Where/when is BeginDoc() issued before you write onto the printer canvas?

The sample does not show the printing of the grid itself. What grid print function is used?

Do you have a more complete example?

thanks in advance


more questions re: example 9

PrintPageWidth, PrintColWidth, etc., units are indicated as pixels. Presumably these are printer canvas pixels (?), so the printer must already be selected before they can be used. Correct?

However, these are used in the example as if they are in LO_METRIC 0.1 mm units. I don't see a conversion to logical units. What am I not understanding?

Thanks for your patience


  1. The Canvas is the printer canvas.
    2) BeginDoc /EndDoc are being invoked by the grid 
    3) The printer is already selected before printing starts, i.e. also before this event to do custom drawing is triggered
    4) The grid uses LO_METRIC. When the event is invoked, the printer canvas units were set by the grid to LO_METRIC

ok, thanks. Understanding is improving.

PrinterSettings->HeaderSize and others are in logical units, not pixels

Rad Studio has this wrong also for TextHeight, which is in logical units -- not pixels

This obviously makes a big difference when doing canvas calcs.

We are unable to set grid->PrintSettings dynamically while in the PrintPage event. They apparently must be set before. Can you confirm?

To establish grid->PrintSettings, we have had to do:

printer->BeginDoc // to access the printer canvas

.. setup grid->PrintSettings using printer canvas metrics and our fonts


then, grid->Print();

Ideally, we could do all this with a single function called from PrintPage.


I'm not sure what exactly you want to achieve?

Why do you need to dynamically set grid.PrintSettings? Why do you need the printer canvas for setting grid.PrintSettings?

We use the printer canvas to determine the space needed for the header strings, with our fonts, for TextHeight, TextExtents, etc. Devicecaps needs the printer handle, so why not go to the canvas?   Is there a better way?

Dynamically setting PrintSettings: for example, so HeaderSize on page 2 can be different than on page 1. Not a top priority, but would be useful.



If you put the display canvas in MM_LOMETRIC mapmode, it should allow you to do the same measurements using the display canvas. Have you considered this?

No, but that should work.

Thanks for the tip !