Topic Options
#29671 - 10/02/07 08:39 PM Another function in PP Design
jackping Offline
OL Newbie

Registered: 07/10/07
Posts: 17
Loc: Auckland
sometime 1 string can be so long that we have to use 2 or more lines to display it. Is it possible to add a function which can calculate how many lines need to use in order to display a particular string? This will affect the total number of page for a document as well.

#29672 - 10/03/07 12:57 PM Re: Another function in PP Design
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1948
Loc: Objectif Lune, Montreal, Qc
When using proportional fonts or fonts with different attributes (Size, boldness, etc.), it's impossible to compute the number of lines a specific string requires unless you "run" the object first. But of course, "running" the object means you have to print it, and by then it's too late...

But you still have a couple of options here:

1. Use a Monospaced font for the entire string. You can then use the PlanetPress Talk stringwidth( ) function to compute the total length of the string and then divide that by the actual width of the space within which you want to print it. This will not yield entirely accurate results as the line wrap function may affect where each line breaks, but it's usually a pretty good approximation.

2. Duplicate the text object that contains the string to display, and position that second object outside the printable area on the page. Make sure the duplicated object is the first to be run on the page (or at the very least, that it is positioned before the actual object that will print). In that duplicated object, you can insert code in the PressTalkBefore and PressTalkAfter events to calculate the actual height of the box. You then store that value in a global variable, which you can use later on on the page to adapt the behavior of the original object. Since the duplicated object is placed outside the printable area, it won't show up on the hard copy of your document, or on the PDF version if you use PlanetPress Image.

I hope this helps.
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen