Невозможно получить все поля с помощью PDFSharp в .NET.C#

Место общения программистов C#
Anonymous
Невозможно получить все поля с помощью PDFSharp в .NET.

Сообщение Anonymous »

У меня есть PDF-файл с редактируемыми полями формы, имеющими 10 полей ввода. Пять из полей ввода имеют имя типа (возраст, пол, дата рождения, местоположение, адрес). Остальные пять имеют лайки по именам (ticket.id, event.name, Seat.row, Seat.tag, Ticket.eventdate).

Код: Выделить всё

    PdfDocument templateReader = PdfReader.Open(templateStream, PdfDocumentOpenMode.Modify);

IDictionary fieldVals = mergeItem.MergeFieldValues;
PdfAcroForm form = templateReader.AcroForm;
form.Elements.SetName("/NeedAppearances", "true");
form.Elements.SetBoolean("/NeedAppearances", true);

if (form != null && form.Fields.Count > 0)
{
foreach (string fieldName in form.Fields.DescendantNames)
{
PdfAcroField field = form.Fields[fieldName];

if (field is PdfTextField textField && fieldVals.ContainsKey(textField.Name))
{
textField.Value = new PdfString(fieldVals[textField.Name]);
textField.ReadOnly = true;
textField.Text = fieldVals[textField.Name];
textField.MultiLine = true;
textField.Font = new PdfSharp.Drawing.XFont("Arial", 30, XFontStyleEx.Regular);

}
}
form.Elements.SetBoolean("/NeedAppearances", true);
}
Использование form.Fields.DescendantNames возвращает 10 элементов, но поле PdfAcroField = form.Fields[fieldName]; возвращает только поля (возраст, пол, дата рождения, местоположение, адрес).
Как мне получить доступ к другим полям.

Подробнее здесь: https://stackoverflow.com/questions/790 ... arp-in-net

Вернуться в «C#»