empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
492 stars 114 forks source link

unable to check if a PdfDocument has an AcroForm inside #115

Open fedebona opened 5 months ago

fedebona commented 5 months ago

Reporting an Issue Here

If I open a PdfDocument PdfDocument inputPDFDocument = PdfReader.Open(pdfFile, PdfDocumentOpenMode.Import);

I'm not able to check if it has an AcroForm inside.

Expected Behavior

I should be able to check something like inputPDFDocument.AcroForm != null

Actual Behavior

inputPDFDocument.AcroForm raises an invalidoperation exception

Steps to Reproduce the Behavior

bool hasForm = (inputPDFDocument.AcroForm != null && inputPDFDocument.AcroForm.Elements.Count > 0); //unwanted Exception raised