diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc index d331632..0c71ae3 100644 --- a/libqpdf/QPDFAcroFormDocumentHelper.cc +++ b/libqpdf/QPDFAcroFormDocumentHelper.cc @@ -413,7 +413,7 @@ AcroForm::traverseField(QPDFObjectHandle field, QPDFObjectHandle const& parent, // be there to be inherited by annotations below it. FormNode node = field; - const bool is_field = depth == 0 || node.field(); + const bool is_field = node.field(); const bool is_annotation = node.widget(); QTC::TC("qpdf", "QPDFAcroFormDocumentHelper field found", (depth == 0) ? 0 : 1); diff --git a/libqpdf/qpdf/AcroForm.hh b/libqpdf/qpdf/AcroForm.hh index 814a004..ecfc301 100644 --- a/libqpdf/qpdf/AcroForm.hh +++ b/libqpdf/qpdf/AcroForm.hh @@ -644,19 +644,19 @@ namespace qpdf::impl /// no value is found. std::string default_appearance() const; - /// @brief Determines whether the form node represents a field (does not apply to root - /// fields). + /// @brief Determines if the current node represents a valid form field node. /// - /// This method checks if the current node represents a field by examining two conditions: - /// 1. The presence of children nodes (via the `/Kids` array). - /// 2. Whether it contains the `/Parent` key. + /// This function evaluates whether the current node is valid by combining + /// checks for the node's partial name (/T attribute), its immediate descendants + /// (/Kids array), and its field type (/FT attribute). It ensures that at least + /// one of these properties exists or returns a valid value. /// - /// @return `true` if the node represents a field (either has children or contains a - /// `/Parent` key), otherwise `false`. + /// @return true if the form node contains a valid /T attribute, /Kids array, + /// or /FT attribute; otherwise, false. bool field() const { - return Kids() || contains("/Parent"); + return T() || Kids() || FT(); } /// @brief Determines if the form node represents a widget annotation.