Detect form fields¶
This operation opens the PDF with iTextSharp and inspects its AcroForm to determine whether it carries interactive form fields.
| Field | Value |
|---|---|
| Operation ID | OP-06 |
| Trigger | Caller invokes HasFormFields(byte[] file) |
| Inputs | PDF bytes |
| Outputs | true / false |
| Primary components | PdfAPI.Core.PdfClientService.HasFormFields |
| Entry point | PdfAPI.Core\Services\PdfClientService.cs |
Steps¶
- Run Validate PDF bytes to guard the input. (BR-01, BR-02, BR-03)
- Open an iTextSharp
PdfReaderover the bytes. - Return
falsewhenreader.AcroFormis null. (BR-10) - Otherwise return whether
reader.AcroFields.Fields.Count > 0. (BR-10)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["HasFormFields(bytes)"]) --> Guard["OP-01: ValidatePdf"]
Guard --> Open["Open PdfReader"]
Open --> Form{reader.AcroForm null?}
Form -->|Yes| False([Return false])
Form -->|No| Count{AcroFields.Fields.Count > 0?}
Count -->|Yes| True([Return true])
Count -->|No| False2([Return false])
Failure and edge-case behavior¶
- A PDF with an AcroForm dictionary but zero fields still reports
false.
Related documentation¶
Sources¶
PdfAPI.Core\Services\PdfClientService.cs