## Printing text using specific justification or word-wrap

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

### Printing text using specific justification or word-wrap

Hi Kambiz

Just stumbled on your TPrintPreview... Impressive !

I wonder if you can help me with the following:
I need to print an unknown amount of text, wordwrapped inside a cell (sort of like in Excel), or even filled, or otherwise justified.
Currenly I manually perform these tasks, and it works, but I wonder if there are better ways to do this:
Maybe mis-use the TRichedit for that purpose,
maybe even there is a windows way to just inform windows that text is to be printed in a word-wrap way, or using a certain justification, to a certain rectangular area...

Since you obviously are very aware of all print-possibilities, please give me your advise on how to handle this.

Thanks.

Ron Gommers
ron@itsoftware.nl

lancelot59
Member

Posts: 4
Joined: June 21st, 2005, 11:31 am
Location: The Netherlands

The rich edit contorl comes with Delphi is too poor. Try to use a third party rich edit control. I personally use RxRichEdit that comes with RxLib, but I know there are even better rich edit controls on the net for free.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Ok, so you use RxRichEdit.
But what I wanted to know if there is another way to force text to be printed "wrapped" to a certain rectangle. Image printing a few thousand cell's from a spreadsheet, and having to go to a RichEdit to be able to format every separate cell.

A few other questions:
1. Word as well as rtf can use fontsize 7.5, how would I be able to do the same ?
2. Would it be possible to have a configurable resolution, currently fixed to screen.pixelsperinch. So when creating pages for display, they could be created assuming 300dpi or 600dpi or whatever, just to be able to really zoom into what is going to be printed.

Thanks...

Ron.

lancelot59
Member

Posts: 4
Joined: June 21st, 2005, 11:31 am
Location: The Netherlands

sorry, "Image printing..." should be "Imagine printing..."

lancelot59
Member

Posts: 4
Joined: June 21st, 2005, 11:31 am
Location: The Netherlands

Hi,

By using PaintRichText method of PrintPreview, you can print a rich text in any rectangle.

For setting the font size as a real number you can use the following code:
Code: Select all
Font.Height := -Round(SizeOfFont * Screen.PixelsPerInch / 72);

Using a higher than actual screen resolution makes the result larger than the actual size. The current code gererates the correct result.
Kambiz

Kambiz