Class: CorpPdf::Actions::RemoveField

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/corp_pdf/actions/remove_field.rb

Overview

Action to remove a field from a PDF document

Instance Method Summary collapse

Methods included from Base

#acroform_ref, #apply_patch, #find_page_by_number, #get_object_body_with_patch, #next_fresh_object_number, #patches, #resolver

Constructor Details

#initialize(document, field) ⇒ RemoveField

Returns a new instance of RemoveField.



9
10
11
12
# File 'lib/corp_pdf/actions/remove_field.rb', line 9

def initialize(document, field)
  @document = document
  @field = field
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/corp_pdf/actions/remove_field.rb', line 14

def call
  af_ref = acroform_ref
  return false unless af_ref

  # Step 1: Remove widget annotations from pages' /Annots arrays
  remove_widget_annotations_from_pages

  # Step 2: Remove from /Fields array
  remove_from_fields_array(af_ref)

  # Step 3: Mark the field object as deleted by setting /T to empty
  mark_field_deleted

  true
end