Skip to content

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

  1. Run Validate PDF bytes to guard the input. (BR-01, BR-02, BR-03)
  2. Open an iTextSharp PdfReader over the bytes.
  3. Return false when reader.AcroForm is null. (BR-10)
  4. 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.

Sources

  • PdfAPI.Core\Services\PdfClientService.cs