Method: Prawn::Document#initialize
- Defined in:
- lib/prawn/document.rb
#initialize(options = {}, &block) ⇒ Document
Creates a new PDF Document.
Setting e.g. the ‘:margin` to 100 points and the `:left_margin` to 50 will result in margins of 100 points on every side except for the left, where it will be 50.
The ‘:margin` can also be an array much like CSS shorthand:
“‘ruby # Top and bottom are 20, left and right are 100. margin: [20, 100] # Top is 50, left and right are 100, bottom is 20. margin: [50, 100, 20] # Top is 10, right is 20, bottom is 30, left is 40. margin: [10, 20, 30, 40] “`
Additionally, ‘:page_size` can be specified as a simple two value array giving the width and height of the document you need in PDF Points.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/prawn/document.rb', line 227 def initialize( = {}, &block) = .dup Prawn.(VALID_OPTIONS, ) # need to fix, as the refactoring breaks this # raise NotImplementedError if options[:skip_page_creation] self.class.extensions.reverse_each { |e| extend(e) } self.state = PDF::Core::DocumentState.new() state.populate_pages_from_store(self) renderer.min_version(state.store.min_version) if state.store.min_version renderer.min_version(1.6) if [:print_scaling] == :none @background = [:background] @background_scale = [:background_scale] || 1 @font_size = 12 @bounding_box = nil @margin_box = nil @page_number = 0 @text_formatter = .delete(:text_formatter) || Text::Formatted::Parser [:size] = .delete(:page_size) [:layout] = .delete(:page_layout) initialize_first_page() @bounding_box = @margin_box if block block.arity < 1 ? instance_eval(&block) : block[self] end end |