I'm trying to add choices to a List-field within a pdf form via C# and the itextsharp library. But i cant find a way to do this. The form already exists, i created it with Acrobat. I would like that the Listfield choices from the PDF are the same as in my program. Therefore I want to create the options in the list-fields via itextsharp to reduce the maintenance. But I cant find away to do this. With the PDFstamper from the library I am able to fill the Fields from the form. And Color some fields. Is there a possibility to add options to a List-field via c# Code ? Would be great if someone knows the answer and shows me a way to realize this.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- Correctly parse PDF paragraphs with Python
- 求获取指定qq 资料的方法
If you are using iText 7, it's easy. That's explained in chapter 5 of the iText 7 jump-start tutorial: Manipulating an existing PDF document
iText 7 currently only exists for Java; the C# version will be released in 2 weeks.
If you are using iText 5, then you need to consult Chapter 8 of iText in Action - Second Edition, more specifically at the ChoiceFields example:
The code above is Java code, but you could also interpret it as "pseudo code" if you don't want to read Java.
All the examples from the iText in Action book are converted to C#. See ChoiceFields.cs for the full iText 5 example.
Important: I am assuming that you have created the form with Acrobat and that your form is based on AcroForm technology. If you have created your form with LiveCycle, you have an XFA form. The code shared in this answer will not work for XFA forms.