def calculate_header
            headers = []
            height = 0
            @current_groups.each do |field, current_value|
                identifier_field = @sections[:groups][field.to_sym][:settings][:identifier_field] || nil
                value = (!@record.class.reflect_on_association(field).nil? and !identifier_field.nil?) ? @record.send(field.to_sym).send(identifier_field) : @record.send(field)

                if value != current_value
                    reset_groups_values field

                    headers << field.to_sym
                    height += @sections[:groups][field.to_sym][:settings][:height] + @sections[:groups][field.to_sym][:settings][:posY]

                    @current_groups[field] = value
                end
            end unless @current_groups.empty?

            [headers, height]
        end
def calculate_header
            headers = []
            height = 0
            @current_groups.each do |field, current_value|
                identifier_field = @sections[:groups][field.to_sym][:settings][:identifier_field] || nil
                value = (!@record.class.reflect_on_association(field).nil? and !identifier_field.nil?) ? @record.send(field.to_sym).send(identifier_field) : @record.send(field)

                if value != current_value
                    reset_groups_values field

                    headers << field.to_sym
                    height += @sections[:groups][field.to_sym][:settings][:height] + @sections[:groups][field.to_sym][:settings][:posY]

                    @current_groups[field] = value
                end
            end unless @current_groups.empty?

            [headers, height]
        end
Calculates the headers which must be printed before print the current record.
The function also returns the current header height to create a new page if the
page remaining space is smaller than (header + a record height)