Board index » cppbuilder » Printing from TRichEdit

Printing from TRichEdit

Greetings BCBers,

I have a TRichEdit component that holds the output of a text report (set
w/courrier font).
I am trying to print the contents of the rich edit so that the output is 66
lines per page, followed by
a form feed.
The problem is the Rich Edit Print() does not recognize the form feed.

How can I get the rich edit to print (using the Print() method), to
recognize and send through the form feed so
that the text will do a page break properly on the printer output?

Thanks for the help,
Curt Cearley

 

Re:Printing from TRichEdit


Hi, Curt.

Quote
> I have a TRichEdit component that holds the output of a text report (set
> w/courrier font).
> I am trying to print the contents of the rich edit so that the output is 66
> lines per page, followed by
> a form feed.
> The problem is the Rich Edit Print() does not recognize the form feed.

> How can I get the rich edit to print (using the Print() method), to
> recognize and send through the form feed so
> that the text will do a page break properly on the printer output?

You might want to check out http://home.att.net/~robertdunn/Yacs.html.
I *think* that I have covered this fairly thoroughly there.

HTH.

robert

Re:Printing from TRichEdit


Keep a careful count of lines added to the RE.

Calculate exact lines to fit on the printer page.

Where you want a form feed add extra blank lines into the RE, so that lines
(including blanks) in the RE = lines per printer page.

Works perfectly for me. As follows:

    int a = Printer()->PageHeight; // pixels
    int b = Printer()->PageWidth; // pixels
    int d = Printer()->Canvas->TextWidth("X"); // +pixels
    int e = Printer()->Canvas->TextHeight("X"); // +pixels
    lpp = a/e; // assume correct rounding, do not change sign
    cpl = b/d; // characters per line
    sprintf(resp,"Lines per page = %d",lpp);
    LPP->Caption = resp;
    sprintf(resp,"Characters per line = %d",cpl);
    CPL->Caption = resp;

Obviously widths only work for non-proportional fonts.And don't forget
BeginDoc/AbortDoc first.

 Printer()->BeginDoc();
  Printer()->Abort();   // works fine

Quote
Curt Cearley wrote:
> Greetings BCBers,

> I have a TRichEdit component that holds the output of a text report (set
> w/courrier font).
> I am trying to print the contents of the rich edit so that the output is 66
> lines per page, followed by
> a form feed.
> The problem is the Rich Edit Print() does not recognize the form feed.

> How can I get the rich edit to print (using the Print() method), to
> recognize and send through the form feed so
> that the text will do a page break properly on the printer output?

> Thanks for the help,
> Curt Cearley

Other Threads