Page 1 of 1

RichEdit lines printed per page

Posted: Tue May 07, 2019 3:24 pm
by emeasoft
Hi,

There is a way to retrieve the number of lines that can be printed per page using a RichEdit?
Considering I'm using a A4 paper, that is 210x297mm sized, I need to fix the first and last line printed in each page.
Counting the number of lines doesn't help, cause the text font size can vary and it leads the "fixed" lines to be printed in the wrong places.

What the "GetPrintHeight" RichEdit method returns exactly?

TIA,

André Corrêa

Re: RichEdit lines printed per page

Posted: Fri May 10, 2019 11:46 am
by ignacio
Hi,

Sample send from Pedro Gil (Our RichEdit master):

Code: Select all

    // A4 -> 2100 x 2970 mm;
    // Left margin = 250 mm;
    // Top margin = 150 mm;

    LOCAL aRect := { 250, 150, 1850, 2820 } // left, top, right, bottom [size of printing area]
    LOCAL nFrom := 0 // first char to be printed

    Printer:lPreview := .T.
    Printer:StartDoc()
    Printer:StartPage()
    Printer:oCanvas:nMapMode := mmHIMETRICS

    WITH OBJECT Printer:oCanvas
       WHILE ( nFrom := :DrawRichEdit( aRect, oRichEdit, nFrom ) ) != -1 // end of file

          MsgInfo( nFrom ) -> Last char printed per page
          MsgInfo( oRichEdit:GetLineFromChar( nFrom ) ) -> Last line printed per page

       ENDDO
    END

    Printer:EndPage()
    Printer:EndDoc()

Re: RichEdit lines printed per page

Posted: Fri May 10, 2019 2:44 pm
by emeasoft
Hi,

I'll try it, thank you very much, Ignacio and Pedro!

Cheers,

André Corrêa