我尝试通过.net代码向PDF文件的域中填写指定的信息,但是在填写保存后,文本域中的内容就变成了乱码,请问怎么解决这一问题,还是我的赋值手段有问题?
//获取文档的所有域
PdfFormWidget form = pdf.Form as PdfFormWidget;
for (int i = 0; i < form.FieldsWidget.Count; i++)
{
string fieldName = form.FieldsWidget[i].Name;
//填充文本域
PdfTextBoxFieldWidget textboxField = form.FieldsWidget[i] as PdfTextBoxFieldWidget;
if (textboxField.Text.Trim() != fieldNames[fieldName].ToString().Trim())
{
textboxField.Text = fieldNames[fieldName].ToString();
}
}
PdfFormWidget form = pdf.Form as PdfFormWidget;
for (int i = 0; i < form.FieldsWidget.Count; i++)
{
string fieldName = form.FieldsWidget[i].Name;
PdfComboBoxWidgetFieldWidget comboBoxField = form.FieldsWidget[i] as PdfComboBoxWidgetFieldWidget;
if (comboBoxField.SelectedIndex[0] != fieldNames[fieldName].ToInt())
{
comboBoxField.SelectedIndex = new int[] { fieldNames[fieldName].ToInt() };
}
}