AcroFields' funcion setField doesn't add apostrophe on VB.NET

45 views Asked by At

When adding a string that contains an apostrophe by using the AcroFields' method "SetField", the function removes the apostrophe from the string.

I tried to use a single accent but it was removed as well.

1

There are 1 answers

0
user20716902 On

The reason you are seeing this issue is because the font that is being used doesn't support certain characters, there are two solutions:

  1. Replace the apostrophe character with `

  2. Set the field to use a font that does support the apostrophe like this:

    BaseFont fieldFont = 
    BaseFont.CreateFont(@"C:\Windows\Fonts\timesnr.ttf", 
                                 BaseFont.IDENTITY_H, 
                                 BaseFont.EMBEDDED); 
    
    myDoc.AcroFields.SetFieldProperty("myField", "textfont", fieldFont, null);