Subject: PdfTextBoxField does not allow all characters to be entered in the textbox
Date: 2014-08-11 11:09:04
From: Yaakov Ellis
Source: pdftextboxfield-not-allow-characters-entered-textbox
----------------------------------------------------------------------

I initialized as follows:

       internal static FontFamily fontArial = new FontFamily("Arial");

      internal static PdfTrueTypeFont font9 = new PdfTrueTypeFont(new Font(fontArial, 9), 9, true);        

        var textBox = new PdfTextBoxField(page, resourceKey);
        
        textBox.Bounds = textBoxRect; // already defined
        textBox.Font = font9;
        textBox.Password = false;
        textBox.Multiline = false;
        textBox.ForeColor = new PdfColor(Color.Black);
        textBox.BorderWidth = 0;
        textBox.DisableAutoFormat = true;
        textBox.MappingName = resourceKey;
        doc.Form.Fields.Add(textBox);

The form field shows up in the document without issue, However, if I try to enter a non alphanumeric ASCII character - like "@" it just enteres a few spaces in the generated textbox field on the final pdf. 

And if I try to enter a unicode char into the field, like "è" or "à", the pdf does not allow the char to be entered, even though the font is set up to work for unicode (and will work with unicode if I do a regular DrawString() call using the font).

If I initialize the font like this

        internal static PdfTrueTypeFont font9 = new PdfTrueTypeFont(new Font(fontArial, 9), 9, false);
 
 
and this indicate that it is not for unicode, then the non-alphanumeric ASCII char (@) can be entered. Unicode chars still cannot be entered.
 
My expectations

Am I doing something wrong? Or is this a bug?

I am fairly sure that this is an issue with your implementation, since I have never had an issue entering either non-alphanumeric ASCII chars nor Unicode chars into pdf files created with Acrobat.

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index