# File lib/prawn/document.rb, line 157
    def initialize(options={},&block)   
       Prawn.verify_options [:page_size, :page_layout, :margin, :left_margin, 
         :right_margin, :top_margin, :bottom_margin, :skip_page_creation, 
         :compress, :skip_encoding, :text_options, :background, :info], options

       self.class.extensions.reverse_each { |e| extend e }
      
       options[:info] ||= {}
       options[:info][:Creator] ||= "Prawn"
       options[:info][:Producer] = "Prawn"

       options[:info].keys.each do |key|
         if options[:info][key].kind_of?(String)
           options[:info][key] = Prawn::LiteralString.new(options[:info][key])
         end
       end
          
       @version = 1.3
       @store = ObjectStore.new(options[:info])
       @trailer = {}
       @before_render_callbacks = []

       @page_size     = options[:page_size]   || "LETTER"
       @page_layout   = options[:page_layout] || :portrait
       @compress      = options[:compress] || false
       @skip_encoding = options[:skip_encoding]
       @background    = options[:background]
       @font_size     = 12
       @page_content  = nil
       @bounding_box  = nil
       @margin_box    = nil

       @text_options = options[:text_options] || {}
       
       apply_margin_option(options) if options[:margin]

       default_margin = 36  # 0.5 inch
       @margins = { :left   => options[:left_margin]   || default_margin,
                    :right  => options[:right_margin]  || default_margin,
                    :top    => options[:top_margin]    || default_margin,
                    :bottom => options[:bottom_margin] || default_margin  }

       generate_margin_box

       @bounding_box = @margin_box

       start_new_page unless options[:skip_page_creation]

       if block
         block.arity < 1 ? instance_eval(&block) : block[self]
       end
     end