According to the PDF Specification, (found here:
http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.
pdf), the max length is stored under the "MaxLen" key.
I'm no C# (or VB) programmer, but in Java the code would go something
like:
PdfDictionary mergedFieldDictionary = myAcroFields.getFieldItem( key
).getMerged( 0 );
PdfNumber maxLengthNumber = mergedField.getAsNumber( PdfName.MAXLEN );
if (maxLenghtNumber != null) {
MaxFieldLength = maxLengthNumber.intValue();
}
Note that it's perfectly legal to not specify a maximum length, in which
case the field's length is not limited.... though I think that
Reader\etc will truncate to 0xFFFF characters (that's 65,535
characters)... that's an old implementation limit and may have been
raised since Ye Olden Days.
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: Scott Mitchell [mailto:[email protected]]
Sent: Wednesday, October 06, 2010 2:29 PM
To: [email protected]
Subject: [iText-questions] How can I use iTextSharp to determine
a text field's maximum number of characters allowed?
I have a PDF document with a number of text fields, several of
which have a maximum length - namely, a maximum number of allowable
characters.
Is there a way using iTextSharp to determine this setting?
Here's the code I have so far:
Dim reader As New iTextSharp.text.pdf.PdfReader("Foobar.pdf")
Dim inputFields As IDictionary(Of String,
iTextSharp.text.pdf.AcroFields.Item) = reader.AcroFields.Fields
For Each key As String In inputFields.Keys
Dim PDFFieldName As String = key
Dim MaxFieldLength As Integer = ???
...
Next
I need to set MaxFieldLength to the number of allowable
characters for the current form field being iterated over.
Thanks
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.862 / Virus Database: 271.1.1/3170 - Release Date:
10/05/10 23:34:00
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php