class PrawnRails::Document

This derives from Prawn::Document in order to override defaults. Note that the Prawn::Document behaviour itself shouldn't be changed.

Public Class Methods

extensions() click to toggle source
# File lib/prawn-rails/document.rb, line 9
def self.extensions
  Prawn::Document.extensions
end
new(options = {}) click to toggle source
Calls superclass method
# File lib/prawn-rails/document.rb, line 13
def initialize(options = {})
  if PrawnRails.config.respond_to?(:to_h)
    options.reverse_merge!(PrawnRails.config.to_h)
  else
    options.reverse_merge!(PrawnRails.config.marshal_dump)
  end

  super(options)
end

Public Instance Methods

text(value, options = {}) click to toggle source

Typically text expects a string. But Rails views have this interesting concept that they implicitly call `to_s` on all the variables before rendering. So, passing an integer to text fails:

pdf.text 10 #=> fails because 10 is not a string pdf.text 10.to_s #=> works

To circumvent this situation, we call to_s on value, and delegate action to actual Prawn::Document.

Calls superclass method
# File lib/prawn-rails/document.rb, line 29
def text(value, options = {})
  super(value.to_s, options)
end