You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if i try to extract Information from a form there is no form found. Is there any restriction in processing a pdf?
using System;
using System.Linq;
using UglyToad.PdfPig;
using UglyToad.PdfPig.AcroForms;
using UglyToad.PdfPig.AcroForms.Fields;
namespace ConsoleApp1
{
internal class Program
{
public static void Run(string filePath)
{
using (var document = PdfDocument.Open(filePath))
{
bool hasForm = document.TryGetForm(out AcroForm form); // here i get false
if (!document.TryGetForm(out var form2))
{
Console.WriteLine($"No form found in file: {filePath}.");
return;
}
var page1Fields = form.GetFieldsForPage(1);
foreach (var field in page1Fields)
{
switch (field)
{
case AcroTextField text:
Console.WriteLine($"Found text field on page 1 with text: {text.Value}.");
break;
case AcroCheckboxesField cboxes:
Console.WriteLine($"Found checkboxes field on page 1 with {cboxes.Children.Count} checkboxes.");
break;
case AcroListBoxField listbox:
var opts = string.Join(", ", listbox.Options.Select(x => x.Name));
Console.WriteLine($"Found listbox field on page 1 with options: {opts}.");
break;
}
}
}
}
static void Main(string[] args)
{
Run("D:\\test.pdf");
}
}
}
The text was updated successfully, but these errors were encountered:
Hi there's no restrictions on pulling content from PDFs with this library, are you able to share the file with the issue, it's likely an edge-case/non-conformant file that needs additional code to support it.
Im cannot share but i think i know why this problem occured. I think the testing person printed his pdf. So it could be possible the file was flattened and the form objects has been cleared.
Tests with other files were successfully.
Thanks for your reply
Hello,
if i try to extract Information from a form there is no form found. Is there any restriction in processing a pdf?
The text was updated successfully, but these errors were encountered: