Prawn::Document 中没有 make_table 方法
我有一个 Rails 3 应用程序,可以使用 Prawn 生成 PDF 文档。
在 Gemfile 中我有:
宝石“虾”,'= 0.12.0'
宝石“虾布局”
但是,请按照 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}, @identifiers=[1, 2, 3, 4, 5], @info=1、@root=2>、@version=1.3、 @页面=[#, @margins={:左=>36,:右=>36,:上=>36,:下=>36}, @堆栈=#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>], @页=#, @margins={:左=>36,:右=>36,:上=>36,:下=>36}, @堆栈=#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={}、 @压缩=假,@加密=假,@加密密钥=零, @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.方法=> [:边界框,:画布, :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, :重复器,:重复,:大纲,:单元格,:表,:lazy_bounding_box, :填充框,:定义网格,:网格,:邮票,:邮票_at,:创建_邮票, :图像、:移动_到、:线_到、:曲线_到、:矩形、:圆角_矩形、 :line_width=, :line_width, :line, :horizontal_line, :horizontal_rule, :垂直线、:曲线、:圆形、:圆、:椭圆、:椭圆、 :多边形,:圆角多边形,:圆角顶点,:描边, :关闭和描边,:描边边界,:填充,:填充和描边, :关闭路径、:方法缺失、:填充渐变、:笔画渐变、 :旋转、:平移、:缩放、:transformation_matrix、:透明、 :join_style, :join_style=, :cap_style, :cap_style=, :dash, :dash=, :undash, :虚线?, :write_lines_dash, :fill_color, :fill_color=, :笔划颜色、:笔划颜色=、:文本框、:文本、:格式化文本、 :绘制文本,:高度,:格式化高度,:格式化文本框, :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,:加密_文档,:open_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,:注释, :text_annotation, :link_annotation, :ref, :ref!, :deref, :add_content, :名称, :名称?, :before_render, :on_page_create, :taguri=, :taguri, :to_yaml_style,:to_yaml_properties,:syck_to_yaml,:to_yaml,:空白?, :存在?,:存在,:acts_like?,:尝试,:html_safe?,:可复制?, :`、:返回、: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, :is_a, :元类, :to_matcher, :mocha_inspect,:mocha,:reset_mocha,:stubba_method,:stubba_object, :期望,:存根,: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, :<=>, :类,:singleton_class,:克隆,:dup,:initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :信任,:冻结,:冻结?,:to_s,:检查,:方法, :singleton_methods,:protected_methods,:private_methods, :public_methods,:instance_variables,:instance_variable_get, :instance_variable_set, :instance_variable_define?, :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,:抑制,:class_eval, :require_library_or_gem,:调试器,:断点,:pretty_inspect, :suppress_warnings, :==, :等于?, :!, :!=, :instance_eval, :instance_exec, :发送]
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, @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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 Gemfile 中不需要
gem 'prawn-layout'
。正如引用自 https://github.com/sandal/prawn-layout :只需从 Gemfile 中删除
prawn-layout
并重试即可。You do not need
gem 'prawn-layout'
in your Gemfile. As quoted from https://github.com/sandal/prawn-layout :Simply remove
prawn-layout
from your Gemfile and try again.