I also ran into similar issues when trying to cut off the overflow in a
cell. I eventually abandoned the idea and put in hyphenation to get around
However, below is an overflow workaround I was toying with that was never
implemented, but may be of some use:
1. Find the largest character on your PDF output (may entail printing all
of the characters and then measuring). You only need to do this once
(unless you change your face).
2. Now, during your processing, multiply the number of characters in your
string by the largest character width from #1. If it is larger than your
context size, you need to truncate the string. I was writing a "size
truncater" that would find the max characters by the following method:
a. Cut the string in half.
b. Measure the first half. If it is less than your max,
subtract from your max to get what space is left.
c. Do an integer divide of what space is left by your largest
character width from #1. Add this many characters to a.
3. The resulting string from #2 is now your cell data.
OK, it may not be the best method or even totally foolproof, but it was a
direction I was looking into.
Hope it helps even a little.
ampf.de To: [hidden email] cc:
05/19/2005 04:45 Subject: Calculate text width
I want to avoid a line break in a table cell.
So my Idea is to calculate the String width of a cell and cut the String
even if its longer.