programmatically finding PDF form field size

I am using this example to fill a PDF form. How do i determine the maximum allowed character limit for each field ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Meir RivkinFull stack Software EngineerCommented:
its a bit tricky but doable, u can use AcroFields.GetFiledPositions to get field dimentions and then use Graphics.MeasureString to check how many characters can be fit into the field rectangle.

float[] dims = pdfFormFields.GetFieldPositions("f1_01(0)");
disregard the first array entry (its the page value),

the field dimensions are the following:
dims [1]= Left;
dims [2] = Bottom;
dims [3] = Right;
dims [4] = Top;

Meir RivkinFull stack Software EngineerCommented:
so the rectangle to check is:
RectangleF rf = new RectangleF(dims[1], dims[4], dims[3] - dims[1], dims[4] - dims[2]);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
byte1Author Commented:
I use, Graphics.MeasureString was not available
byte1Author Commented:
Could you please give me an example on how i can use MeasureString to determine the size. Thanks.
Meir RivkinFull stack Software EngineerCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.