Board index » delphi » printing word-wrapped long

printing word-wrapped long

Hello,
I have a long piece of text with not cr/lf in it.  I want to print this
out.  For shorter texts I've been using the DrawText API function.
Unfortunately, it does not seem to return how much text fit in the box
Any ideas short of using GetTextExtent several times for each line?
Thanks,
Jochen

 

Re:printing word-wrapped long


Quote
kjaen...@polaris.umuc.edu (Karla Jaenicke) wrote:
>Hello,
>I have a long piece of text with not cr/lf in it.  I want to print this
>out.  For shorter texts I've been using the DrawText API function.
>Unfortunately, it does not seem to return how much text fit in the box
>Any ideas short of using GetTextExtent several times for each line?
>Thanks,
>Jochen

I've got to do exactly the same type of thing in some code I'm
planning to write tomorrow. I thought I'd just read the text into
a memo component (or whatever it's official name is) and then let
it do the word wrapping after which I'll read the memo lines one
by one and then send them to the printer using TextOut().

I haven't tried it though, but can not off hand think of a reason
why it shouldn't work. Well, I hope it does work. ;)
All the best,

Gerhard van Rensburg
South Africa
E-mail: gerh...@pop.onwe.co.za

Re:printing word-wrapped long


Gerhard and Karla,

If you have the VCL source, look in printers.pas to see how the Borland
Engineers did it.  Knowing that, why not use their hard work - simply use:

procedure TForm1.Button1Click(Sender: TObject);
var MyFile: TextFile;
begin
AssignPrn(MyFile);
Rewrite(MyFile);
Writeln(MyFile, S); { - the code in printers.pas will word wrap for you!!!}
System.CloseFile(MyFile);
end;

--
Paul Motyer
pa...@linuxserver.pccity.com.au
SoftStuff, Croydon, Vic,  Australia, 3136.

Gerhard van Rensburg <gerh...@pop.onwe.co.za> wrote in article
<3283a63f.1360...@news.ibi.co.za>...

Quote
> kjaen...@polaris.umuc.edu (Karla Jaenicke) wrote:

> >Hello,
> >I have a long piece of text with not cr/lf in it.  I want to print this
> >out.  For shorter texts I've been using the DrawText API function.
> >Unfortunately, it does not seem to return how much text fit in the box
> >Any ideas short of using GetTextExtent several times for each line?
> >Thanks,
> >Jochen

> I've got to do exactly the same type of thing in some code I'm
> planning to write tomorrow. I thought I'd just read the text into
> a memo component (or whatever it's official name is) and then let
> it do the word wrapping after which I'll read the memo lines one
> by one and then send them to the printer using TextOut().

> I haven't tried it though, but can not off hand think of a reason
> why it shouldn't work. Well, I hope it does work. ;)
> All the best,

> Gerhard van Rensburg
> South Africa
> E-mail: gerh...@pop.onwe.co.za

Other Threads