Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:07:25+00:00 2026-06-02T17:07:25+00:00

I’m trying to remove the character limit from form fields before setting them using

  • 0

I’m trying to remove the character limit from form fields before setting them using iTextSharp. I am able to do this manually using Adobe Acrobat but we are dealing with a large number of PDF documents which we are dynamically stamping the form fields using iTextSharp. We did not build these PDF documents, we are just using them as templates which we are populating with data. I’m wondering if there is a way to remove the character limit of a form field using the api so we don’t have to manually check every field for character limits.

I’m guessing this can be done with the SetFieldProperty method but I’m not sure exactly how.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:07:26+00:00Added an answer on June 2, 2026 at 5:07 pm

    It’s easy if you know the internals of the PDF format! The code below is pretty much the same as the code I wrote for a different type of PDF annotation here. That page will explain things in a little more detail and give you some references. But basically the trick is to loop through each page, then loop through each page’s annotations (form fields fall into this category among other things) and then look for text fields that have their maximum length set and just remove that limitation. All of this work is done on a read-only PdfReader object so once we’re done we need to loop through again and write it back out using a PdfWriter of some sort.

    Below is a full working C# 2010 WinForms app targeting iTextSharp 5.2.1 that shows all of this off. See the comments in the code for further details.

    using System;
    using System.IO;
    using System.Windows.Forms;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    
    namespace WindowsFormsApplication1 {
        public partial class Form1 : Form {
            public Form1() {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e) {
                var inputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.pdf");
                var outputFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "output.pdf");
    
                //Setup some variables to be used later
                PdfDictionary PageDictionary = default(PdfDictionary);
                PdfArray Annots = default(PdfArray);
    
                //Bind a reader to our input PDF
                PdfReader R = new PdfReader(inputFile);
                //Store the number of pages
                int PageCount = R.NumberOfPages;
                //Loop through each page remember that page numbers start at 1
                for (int i = 1; i <= PageCount; i++) {
                    //Get the current page
                    PageDictionary = R.GetPageN(i);
    
                    //Get all of the annotations for the current page
                    Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
    
                    //Make sure we have something
                    if ((Annots == null) || (Annots.Length == 0)) { continue; }
    
                    //Loop through each annotation
                    foreach (PdfObject A in Annots.ArrayList) {
                        //Convert the itext-specific object as a generic PDF object
                        PdfDictionary AnnotationDictionary = (PdfDictionary)PdfReader.GetPdfObject(A);
    
                        //See if this annotation has a WIDGET which would be the UI implementation of a form field
                        if (!AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.WIDGET)) { continue; }
    
                        //See if this annotation is a text field (TX)
                        if (!AnnotationDictionary.Get(PdfName.FT).Equals(PdfName.TX)) { continue; }
    
                        //See if it has a maximum length specified (MAXLEN)
                        if (AnnotationDictionary.Contains(PdfName.MAXLEN)) {
                            //If so, remove it
                            AnnotationDictionary.Remove(PdfName.MAXLEN);
                        }
                    }
                }
                //Next we create a new document add import each page from the reader above
                using (FileStream FS = new FileStream(outputFile, FileMode.Create, FileAccess.Write, FileShare.None)) {
                    using (Document Doc = new Document()) {
                        using (PdfCopy writer = new PdfCopy(Doc, FS)) {
                            Doc.Open();
                            for (int i = 1; i <= R.NumberOfPages; i++) {
                                writer.AddPage(writer.GetImportedPage(R, i));
                            }
                            Doc.Close();
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.