yob / prawn-js

A small extension to prawn that simplifies embedding JavaScript in your PDF files
MIT License
14 stars 16 forks source link

Uninitialized constant Prawn::NameTree #1

Open vspar opened 13 years ago

vspar commented 13 years ago

Simple problem discovered when upgrading to Prawn 0.11.1, the prawn-js module refers to Prawn::NameTree which is no longer valid.

I use the module for add_docopen_js (autoprint PDF).

Example: /Ruby187/lib/ruby/gems/1.8/gems/prawn-js-0.7.1/lib/prawn/js.rb:84

Change Prawn::NameTree to Prawn::Core::NameTree and issue is resolved.

vspar commented 13 years ago

Discovered a better solution, here is the javascript method replaced, this will then work with both old (0.8.4) and new (0.11.1+) Prawn.

def javascript
  if defined? Prawn::NameTree 
    names.data[:JavaScript] ||= ref!(Prawn::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT)) 
  else 
    names.data[:JavaScript] ||= ref!(Prawn::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT)) 
  end 
end
selvamani-subramani commented 10 years ago

I tried changing the code as suggested above but it didn't work for me. I got "Uninitialized constant Prawn::Core". I could not find core file in prawn folder. So I used pdf code for JavaScript function.

  names.data[:JavaScript] ||= ref!(PDF::Core::NameTree::Node.new(self, NAME_TREE_CHILDREN_LIMIT))