Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

FormCalc. Getting the number of text lines in a cell

Avatar

Not applicable

Hi all!

I have a PDF form with a flowed table. One row of this table contains long namings. So, the cells with these naming have several lines of text.

I have a script calculating table height as sum of all cell heights (I use it later to insert page breaks depending on some conditions).

The problem is that I can't exactly figure out the number of text lines in a cell only according to the text length (some really long words are transfered to the next line having half of the line blank space).

Is there a method I can use to get the number of text lines in a cell? Besides that, I need to know it before the layout:ready event.

Thanks in advance.

0 Replies

Avatar

Level 8

Well, if you truly need it before the layout event fires, the only thing I could suggest is using a mono-spaced font style like courier, in which the width of all characters are the same. Then count how many characters can fit on a line and divide that by the length of the string to get the number of lines.

nLines = myCell.rawValue.length/intCharactersInALine

Kyle

Avatar

Not applicable

Hi, Kyle!

First of all thanks for your reply, I really appreciate your willing to help.

The matter is that I've already done like this. The problem starts when I have some really long word somewhere in a line consisting of, for example, 20 characters. Just to be more clear let's take that one line can fit 50 characters. If this long word occurs at the middle of the line, it doesn't fit and goes to the next line. So, my first line contains about 30 characters and the second may be 50 characters long. Thus, 90-characters text may be split into 2 or 3 lines.

And I can't count the whole table length correctly, having problems with inserting page breaks later.

I don't know, is there a possibility to use hyphenation, but I'm not allowed to use it anyway.

Unfortunately, googling didn't result in my finding some built-in FormCalc method which could allow doing smth like what I need.

I even tried searching line feed symbol in a cell.rawValue praying that Adobe does some kind of substitution for itself. Of course, it turned into a fail.

As for I needed a quick fix for that, I found some "magic numbers" of symbols, when I can suppose the cell is 2-3-4-5 lines length. But it is definitely not even a workaround, it'll work just until another "unconvenient" text will happen.

So, my question is still open.

If you need more details why I need to know the number of lines in a cell, maybe my previous question (still without an answer) will clarify it. The present issue is a workaround for my previos problem: 

http://forums.adobe.com/thread/1162001?tstart=60

And as usual, this workaround is almost good, but...