Retrieving data from PDF using C #

I have a previous pdf with a few dropdowns. I would like to get a list of options from these lists in a C # program.

I looked at iText but couldn't figure out if it can do what I want.

Any suggestions would be greatly appreciated. Thanks in advance!

+3
source share
2 answers

iText [Sharp] can really do what you want:

PdfReader read = new PdfReader(pdfPath);
AcroFields af = reader.getAcroFields();

String displayOptions[] = af.getListOptionDisplay(fldName);
String valueOptions[]   = af.getListOptionValue(fldName);

This Java code wrote off the cuff in the "Your answer" box, but I suspect C # will be very similar.

(Is anyone else so used to the built-in extensions that they expect it outside their IDE? I keep deleting ctrl-space and expect to see a list of available functions.: /)

- , , - , . , . , ... . .

+2

Docotic PDF Library. .

:

using System.Collections.ObjectModel;
using BitMiracle.Docotic.Pdf;

namespace BitMiracle.Docotic.Samples
{
    public static class ReadComboOptions
    {
        public static void Main()
        {
            using (PdfDocument document = new PdfDocument("DocumentName.pdf"))
            {
                PdfCollection<PdfWidget> widgets = document.Pages[0].Widgets;
                foreach (PdfWidget widget in widgets)
                {
                    PdfComboBox comboBox = widget as PdfComboBox;
                    if (comboBox != null)
                    {
                        foreach (string item in comboBox.Items)
                        {
                            // do something with combo box option
                        }
                    }
                }
            }
        }
    }
}

: .

+1

Source: https://habr.com/ru/post/1761362/


All Articles