Free Support Forum -

Get Length of TextField in PDF file

I am using aspose v18.4 to extract fields from PDF files.
Suppose I have a textField control “Name”.
I am able to extract the field control name from that PDF file.
But I need Length of that textField control, means maximum how many characters it can contains.
Can anyone help how to achieve this.

Thank you.


Thank you for contacting support.

You may read Width property exposed by Field class as in the code snippet below:

        Document pdfDocument = new Document(dataDir + "Test.pdf");
        foreach (Aspose.Pdf.Forms.Field formField in pdfDocument.Form.Fields)
            Console.WriteLine("Width : {0} ", formField.Width);

Please note that the basic measuring unit in Aspose.PDF for .NET is point, where 1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thank you @Farhan.Raza for your response.

But my queston was that how could I know that how many characters can contains in the text field?
I tried to use the property MaxLen to get the maximum number of characters it can contain but it retrun to me -1, and some text field returns extact length.
Here what is the meaning of formField.MaxLen = -1?
Is there any other way to get the max Length of Text Field box in PDF file?.

Thank You.


MaxLen property gets or sets maximum length of text in the field, so it is the right approach to get maximum length of text. Would you please share a source file reproducing this behavior so that we may try to reproduce and investigate it in our environment.

Thank you for reply @Farhan.Raza

I have attached sample file in which you can Find Page#2 there is label named *Provider Name and having Text Field below label. In this I am getting MaxLen is -1 but actually it can contain 109 digits and 90 Characters.

But *State/Province it can contain max 2 characters and it returns me 2 in MaxLen property of text field.

Please find the attachment.

Thank you.

SampleAetna.pdf (730.2 KB)


Thank you for sharing requested data.

We have been able to reproduce the issue in our environment. A ticket with ID PDFNET-45275 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

@Farhan.Raza Hope you are doing well.
Is there any Update regarding the Issue we discussed in last week?

Thank you for you support.


Please note that the ticket reported by you has been logged under free support model and such issues are resolved on first come first serve basis because of low priority. Therefore, resolution of your ticket can take some months.

However, we also offer Paid Support, where issues are used to be investigated with higher priority. Our customers, who have paid support subscription, report their issue there which are meant to be investigated urgently. In case your reported issue is a blocker, you may please consider subscribing for Paid Support. For further information, please visit Paid Support FAQs.