to justify a paragraph in report pdfinclude

jorgehh12

New Member
hello to all.

I have a report that shows a paragraph of 5 lines and I want that the same appear just.
The lines leave from a variable that contains a only text, by space questions are due to divide in 5.
For example, the only variable is called wktexto and contained:
wktexto = "Talk to me softly There's something in your eyes Don't hang your head in sorrow And please don't cry I know how you feel inside I've
I've been there before Something's changing inside you And don't you know".
I want that in the report it leaves thus:

Talk to me softly There's something in your eyes Don't hang your head in
sorrow And please don't cry I know how you feel inside I've I've been the
re before Something's changing inside you And don't you know

that instruccion I must use so that prints the just paragraph?

Best Regards.
 
My solution to this is to store each word and space into a temp-table and store it's length. At the same time of storing the values into the temp-table create a counter of the total lengths and test to see if the total value is equal or exceeds to width of your paragraph length.

At this point work back one word and calculate number of units remaining and divide it by the number of spaces (let's say this is "x" ) in sentence of the paragraph. Then output each word and pad it out with "x". Simple.

I would issue some source code put unfortunately it's so integrated into our own code library that it's not portable unless i distribute the current code core or I re-write the code from scratch.


|-----------------------------------------| <----- Y = paragraph
I test this with a bunch of random words: POP


Code:
TEMP-TABLE DATA AND WORD LENGTH COUNTER:
I                     = 1 + 0 = 1 
                      = 1 + 1 = 2 
test                 = 4 + 2 = 6
                      = 1 + 6 = 7
with                 = 4 + 7 = 11 
                      = 1 + 11 = 12
a                     = 1 + 12 = 13
                      = 1 + 13 = 14
bunch              = 5 + 15 = 19
                      = 1 + 19 = 20
random            = 6 + 20 = 26
                      = 1 + 26 = 27
words:             = 6 + 27 = 32
                      = 1 + 32 = 33
POP                 = 3 + 33 = 36

The word POP would exceed the paragraph length ("y") so we work back one word. x = r/s r= number spaces remaining and s= number spaces. The for each word separate by x length.

Hope this help and makes sense.
 
Back
Top