Пример #1
0
        private void Action_GetField(string pdfPath, string field)
        {
            if (System.IO.File.Exists(pdfPath) == false)
            {
                MessageBox.Show("File does not exist");
                return;
            }

            PdfDocument doc = PdfDocument.Load(pdfPath);

            IEnumerable <int> selectedPages = GetSelectedPages(doc.Pages.Count);
            var fieldData = new List <string>();
            int pageNum   = 0;

            foreach (PdfDocumentPage page in doc.Pages)
            {
                pageNum++;
                if (selectedPages.Contains(pageNum) == false)
                {
                    continue;
                }
                PdfTextExtractor extractor = new PdfTextExtractor(page);
                fieldData.Add(extractor.GetFieldAsString(field));
            }
            txtOutput.Lines = fieldData.ToArray();
        }