开发者

No make_table method in Prawn::Document

开发者 https://www.devze.com 2023-04-05 12:01 出处:网络
I have a Rails 3 app that produces PDF documents using Prawn. In the Gemfile I have: gem \"prawn\", \'= 0.12.0\'

I have a Rails 3 app that produces PDF documents using Prawn.

In the Gemfile I have:

gem "prawn", '= 0.12.0'

gem 'prawn-layout'

However, following the example at https://github.com/sandal/prawn/blob/master/examples/table/bill.rb, I am trying to create a table using the make_table method of the Prawn::Document class. This works fine when I run the example on its own, but not when I run the equivalent code in my Rails environment.

Below is the problem in its simplest version in the Rails console. The make_table method is not in the Document object.

Anyone has any hints?

Thanks!

ruby-1.9.2-p136 :005 > a = Prawn::Document.new =>

@internal_state=#1 0 R, 2=>2 0 R, 3=>3 0 R, 4=>4 0 R, 5=>5 0 R}, @identifiers=[1, 2, 3, 4, 5], @info=1, @root=2>, @version=1.3, @pages=[#, @margins={:left=>36, :right=>36, :top=>36, :bottom=>36}, @stack=#nil, :space=>nil, :phase=>0}, @cap_style=:butt开发者_如何学Python, @join_style=:miter, @line_width=1>]>, @size="LETTER", @layout=:portrait, @content=4, @dictionary=5, @stamp_stream=nil, @stamp_dictionary=nil>], @page=#, @margins={:left=>36, :right=>36, :top=>36, :bottom=>36}, @stack=#nil, :space=>nil, :phase=>0}, @cap_style=:butt, @join_style=:miter, @line_width=1>]>, @size="LETTER", @layout=:portrait, @content=4, @dictionary=5, @stamp_stream=nil, @stamp_dictionary=nil>, @trailer={}, @compress=false, @encrypt=false, @encryption_key=nil, @optimize_objects=false, @skip_encoding=false, @before_render_callbacks=[], @on_page_create_callback=nil>, @background=nil, @font_size=12, @bounding_box=#, @parent=nil, @x=36, @y=756.0, @height=720.0, @width=540.0, @total_left_padding=0, @total_right_padding=0, @stretched_height=nil>, @margin_box=#, @parent=nil, @x=36, @y=756.0, @height=720.0, @width=540.0, @total_left_padding=0, @total_right_padding=0, @stretched_height=nil>, @page_number=1, @y=756.0>

ruby-1.9.2-p136 :006 > a.methods => [:bounding_box, :canvas, :column_box, :span, :margin_box, :margin_box=, :margins, :y, :font_size=, :page_number, :page_number=, :state, :page, :start_new_page, :page_count, :go_to_page, :y=, :cursor, :move_cursor_to, :float, :render, :render_file, :bounds, :reference_bounds, :bounds=, :move_up, :move_down, :pad_top, :pad_bottom, :pad, :indent, :mask, :group, :number_pages, :page_match?, :compression_enabled?, :font, :font_size, :set_font, :save_font, :find_font, :font_registry, :font_families, :width_of, :repeaters, :repeat, :outline, :cell, :table, :lazy_bounding_box, :padded_box, :define_grid, :grid, :stamp, :stamp_at, :create_stamp, :image, :move_to, :line_to, :curve_to, :rectangle, :rounded_rectangle, :line_width=, :line_width, :line, :horizontal_line, :horizontal_rule, :vertical_line, :curve, :circle_at, :circle, :ellipse_at, :ellipse, :polygon, :rounded_polygon, :rounded_vertex, :stroke, :close_and_stroke, :stroke_bounds, :fill, :fill_and_stroke, :close_path, :method_missing, :fill_gradient, :stroke_gradient, :rotate, :translate, :scale, :transformation_matrix, :transparent, :join_style, :join_style=, :cap_style, :cap_style=, :dash, :dash=, :undash, :dashed?, :write_stroke_dash, :fill_color, :fill_color=, :stroke_color, :stroke_color=, :text_box, :text, :formatted_text, :draw_text, :height_of, :height_of_formatted, :formatted_text_box, :skip_encoding, :draw_text!, :process_text_options, :default_kerning?, :default_kerning, :default_kerning=, :default_leading, :default_leading=, :text_direction, :text_direction=, :fallback_fonts, :fallback_fonts=, :text_rendering_mode, :character_spacing, :word_spacing, :encrypt_document, :open_graphics_state, :close_graphics_state, :save_graphics_state, :restore_graphics_state, :graphic_stack, :graphic_state, :rollback, :transaction, :dests, :add_dest, :dest_xyz, :dest_fit, :dest_fit_horizontally, :dest_fit_vertically, :dest_fit_rect, :dest_fit_bounds, :dest_fit_bounds_horizontally, :dest_fit_bounds_vertically, :annotate, :text_annotation, :link_annotation, :ref, :ref!, :deref, :add_content, :names, :names?, :before_render, :on_page_create, :taguri=, :taguri, :to_yaml_style, :to_yaml_properties, :syck_to_yaml, :to_yaml, :blank?, :present?, :presence, :acts_like?, :try, :html_safe?, :duplicable?, :`, :returning, :to_param, :to_query, :instance_values, :instance_variable_names, :copy_instance_variables_from, :to_json, :with_options, :as_json, :dclone, :pry, :binding, :instance_eval_with_params, :is_a, :metaclass, :to_matcher, :mocha_inspect, :mocha, :reset_mocha, :stubba_method, :stubba_object, :expects, :stubs, :unstub, :method_exists?, :pretty_print, :pretty_print_cycle, :pretty_print_instance_variables, :pretty_print_inspect, :to_mongo, :require_or_load, :require_dependency, :require_association, :load_dependency, :load, :require, :unloadable, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :method, :public_method, :define_singleton_method, :id, :object_id, :to_enum, :enum_for, :gem, :silence_warnings, :enable_warnings, :with_warnings, :silence_stderr, :silence_stream, :suppress, :class_eval, :require_library_or_gem, :debugger, :breakpoint, :pretty_inspect, :suppress_warnings, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :send]


You do not need gem 'prawn-layout' in your Gemfile. As quoted from https://github.com/sandal/prawn-layout :

NOTE: prawn-layout has been merged into the main prawn repository as of 2010.02.25 (http://github.com/sandal/prawn), however the stable branch of prawn-layout 0.8.x is still hosted here.

Simply remove prawn-layout from your Gemfile and try again.

    >> pdf = Prawn::Document.new
    pdf.methods.grep /table/
    => [:table, :make_table]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号