How to find the maximum character limits of text box field in PDF using C# and VB.NET
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can find the maximum character limits of text box field in an existing PDF document using C# and VB.NET.
Steps to find the maximum character limits of text box field in PDF programmatically:
- Create a new C# Windows Forms application project.
- Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.
- Include the following namespaces in the Form1.cs file.
C#
using Syncfusion.Pdf.Parsing;
VB.NET
Imports Syncfusion.Pdf.Parsing
- Use the following code snippet to find the maximum character limits of text box field in the existing PDF document.
C#
//Load the PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Form.pdf"); //Get the loaded form PdfLoadedForm loadedForm = loadedDocument.Form; //Get the loaded form field PdfLoadedTextBoxField loadedTextBoxField = loadedForm.Fields[0] as PdfLoadedTextBoxField; //Get the maximum character limit of the text box field int length = loadedTextBoxField.MaxLength; MessageBox.Show("Maximum character limits: " + length); //Close the document loadedDocument.Close(true);
VB.NET
'Load the PDF document Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Form.pdf") 'Get the loaded form Dim loadedForm As PdfLoadedForm = loadedDocument.Form 'Get the loaded form field Dim loadedTextBoxField As PdfLoadedTextBoxField = TryCast(loadedForm.Fields(0), PdfLoadedTextBoxField) 'Get the maximum character limit of the text box field Dim length As Integer = loadedTextBoxField.MaxLength MessageBox.Show("Maximum character limits: " & length) 'Close the document loadedDocument.Close(True)
A complete working sample can be downloaded from PDFSample.zip.
Take a moment to peruse the documentation, where you will find other options like creating a new PDF form, modifying existing form fields, filling form fields, removing editing capability, removing form fields, importing FDF file to PDF, export PDF file to FDF, and adding actions to the form fields with code examples.
Refer here to learn more about PDF forms.
Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
Conclusion
I hope you enjoyed learning about how to find the maximum character limits of text box field in PDF using C# and VB.NET.
You can refer to our PDF feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!