module Prawn::JS
Public Instance Methods
add a Javascript fragment that will execute after the document is printed.
There can only be a single fragment. Calling this function multiple times will override earlier fragments.
# File lib/prawn/js.rb, line 27 def add_did_print_js(script) aa[:DP] = ref!(:S => :JavaScript, :JS => script) end
add a Javascript fragment that will execute after the document is saved.
There can only be a single fragment. Calling this function multiple times will override earlier fragments.
# File lib/prawn/js.rb, line 18 def add_did_save_js(script) aa[:DS] = ref!(:S => :JavaScript, :JS => script) end
add a Javascript fragment that will execute when the document is opened.
There can only be as many fragments as required. Calling this function multiple times will append the new fragment to the list.
# File lib/prawn/js.rb, line 36 def add_docopen_js(name, script) obj = ref!(:S => :JavaScript, :JS => script) javascript.data.add(name, obj) end
add a Javascript fragment that will execute when the document is closed.
There can only be a single fragment. Calling this function multiple times will override earlier fragments.
# File lib/prawn/js.rb, line 46 def add_will_close_js(script) aa[:WC] = ref!(:S => :JavaScript, :JS => script) end
add a Javascript fragment that will execute before the document is printed.
There can only be a single fragment. Calling this function multiple times will override earlier fragments.
# File lib/prawn/js.rb, line 55 def add_will_print_js(script) aa[:WP] = ref!(:S => :JavaScript, :JS => script) end
add a Javascript fragment that will execute before the document is saved.
There can only be a single fragment. Calling this function multiple times will override earlier fragments.
# File lib/prawn/js.rb, line 64 def add_will_save_js(script) aa[:WS] = ref!(:S => :JavaScript, :JS => script) end
Private Instance Methods
create or access the Additional Actions dictionary in the document catalogue. See section 8.5.2 and table 8.47 of the PDF spec
# File lib/prawn/js.rb, line 73 def aa # this entry is only valid in the document catalogue in PDF versions 1.4+. min_version(1.4) @root.data[:AA] ||= {} end
create or access the Javascript Name Tree in the document names dict. See section 3.6.3 and table 3.28 in the PDF spec.
# File lib/prawn/js.rb, line 82 def javascript names.data[:JavaScript] ||= ref!(Prawn::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT)) end