I use iTextSharp 5.5.13 to create pdf file with text AcroFields and in a second step edit the pdf filling the AcroFields with some values.
For some fields i have to set a character spacing, so i use CreateAppearance
method. this is the code:
var appearance = writer.DirectContent.CreateAppearance(box.Width, box.Height);
appearance.SetFontAndSize(baseFont, obj.FontSize);
appearance.SetColorFill(new iTextSharp.text.BaseColor(obj.Color));
appearance.SetCharacterSpacing(obj.CharSpacing);
formField.DefaultAppearanceString = appearance;
formField.SetAppearance(iTextSharp.text.pdf.PdfAnnotation.APPEARANCE_NORMAL, appearance);
writer.AddAnnotation(formField);
this code produce expected pdf result with fine character spacing in editable fields.
The problem is when i edit the pdf to fill AcroFields with:
pdfStamper.FormFlattening = true;
pdfStamper.AcroFields.GenerateAppearances = true;
pdfStamper.AcroFields.SetField(fieldName, fieldValue);
the resulting flattened pdf does not mantain the appearence character spacing...
What's wrong with my code?
Thanks