Resolving Apostrophe Character Being Replaced with Copyright Symbol in Filled PDF AcroForm
Environment
| Version | Product | Author |
|---|---|---|
| 2025.2.520 | RadPdfProcessing | Desislava Yordanova |
Description
Learn how to address the issue where a special symbol (e.g. apostrophe character) is replaced by a copyright (or other) symbol in a filled PDF AcroForm using RadPdfProcessing. When the form is opened for editing in a viewer (like Adobe Acrobat), the character appears correctly as an apostrophe in the editor itself.
This might be reproduced with other symbols as well, not only with the apostrophe character. Usually, such behavior may occur with XFA forms. However, from PDF 2.0 (ISO 32000-2) the XFA forms are depreciated.
Solution
This issue is likely caused by the font encoding used in the AcroForm fields. If the font does not properly support the character encoding for the apostrophe or is not embedded or referenced correctly, such substitution may occur.
To resolve this issue, set the font of the AcroForm fields to one of the 14 standard PDF fonts, such as Helvetica, Times, or Courier. These fonts have broad character support and do not require embedding.
Steps:
- Iterate through all form fields in
RadFixedDocument.AcroForm.FormFields. - Check if the field type is TextBox or CombTextBox.
- Set the widget font and text properties font to
FontsRepository.HelveticaBold.
Code Implementation
Use the following code snippet to update the font for all text fields in the PDF document:
foreach (FormField field in document.AcroForm.FormFields)
{
if (field.FieldType == FormFieldType.TextBox || field.FieldType == FormFieldType.CombTextBox)
{
TextField textBox = (TextField)field;
// Set the font for the text field widgets
textBox.Widgets.First().TextProperties.Font = FontsRepository.HelveticaBold;
// Set the font for the text field text properties
textBox.TextProperties.Font = FontsRepository.HelveticaBold;
}
}
After applying the code, the apostrophe character will render correctly in the filled PDF.