Нет метода make_table в Prawn :: Document - PullRequest
2 голосов
/ 16 сентября 2011

У меня есть приложение Rails 3, которое создает документы PDF с использованием Prawn.

В Gemfile у меня есть:

gem "prawn", '= 0.12.0'

gem 'prawn-layout'

Однако, следуя примеру на https://github.com/sandal/prawn/blob/master/examples/table/bill.rb, Я пытаюсь создать таблицу, используя метод make_table класса Prawn :: Document.Это прекрасно работает, когда я запускаю пример сам по себе, но не тогда, когда я запускаю эквивалентный код в моей среде Rails.

Ниже приведена проблема в ее самой простой версии в консоли Rails.Метод make_table отсутствует в объекте Document.

У кого-нибудь есть намеки?

Спасибо!

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}, @ идентификаторы = [1, 2, 3, 4, 5], @ info = 1,@ root = 2>, @ версия = 1.3, @pages = [#, @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>], @ 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 =: портрет, @ content = 4, @ словарь = 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 =,: поля,: y,: font_size =,: номер_страницы,: page_number =,:состояние,: страница,: start_new_page,: page_count,: go_to_page,: y =,: курсор,: 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 ?, :ression_enabled ?,: font,: font_size,: set_font,: save_font,: find_font,: font_registry,: font_families,:width_of,: ретрансляторы,: 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,: roundnded_rectangle,: line_width =,: line_width,: line,: горизонтальный_лайн,: горизонтальный_руль,: вертикальный_лайн,: кривая,: круг_ат,: круг,: эллипс_ат,: эллипс,: многоугольник,: округленный_полигон,: rounded_vertex,: stroke,: close_and_stroke,: stroke_bounds,: fill,: fill_and_stroke,: close_path,: method_missing,: fill_gradient,: stroke_gradient,: rotate,: translate,: scale,: translation_matrix,: прозрачный,: join_style,:join_style =,: cap_style,: cap_style =,: dash,: dash =,: dash =,: 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!:: 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,: откат,: транзакция,: 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,: имена,: имена ?,: before_renre: taguri =,: taguri,: to_yaml_style,: to_yaml_properties,: syck_to_yaml,: to_yaml,: blank ?,: присутствует ?,: присутствии,: actions_like ?,: try,: html_safe ?,: duplicable ?,: `,: возвращая,: to_param,: to_query,: instance_values,: instance_variable_names,: copy_instance_variables_from,: to_json,: with_options,: as_json,: dclone,: pry,: привязка ,: instance_eval_with_params,: * 1028 is ,: метакласс ,: to_matcher,: mocha_inspect,: mocha,: reset_mocha,: stubba_method,: stubba_object,: ожидает,: заглушки,: unstub,: method_exists ?,: pretty_print,: pretty_print_cycle,: pretty_iable_inst,: 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,: unrusrus ?,: 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,: response_to ?,: response_to_missing ?,: extended,: 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_:,: точка останова,: pretty_inspect,: suppress_warnings,: ==,: равно ?,:!,:! =,: instance_eval,: instance_exec,: send ]

1 Ответ

2 голосов
/ 16 сентября 2011

Вам не нужно gem 'prawn-layout' в вашем Gemfile.Как указано в https://github.com/sandal/prawn-layout:

ПРИМЕЧАНИЕ: макет креветок был объединен с основным хранилищем креветок по состоянию на 2010.02.25 (http://github.com/sandal/prawn),, однако стабильная ветвь макета креветок 0,8.x все еще находится здесь.

Просто удалите prawn-layout из своего Gemfile и попробуйте снова.

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