    # File lib/prawn/pdf_object.rb, line 29
      def PdfObject(obj, in_content_stream = false)
        case(obj)
        when NilClass   then "null"
        when TrueClass  then "true"
        when FalseClass then "false"
        when Numeric    then String(obj)
        when Array
          "[" << obj.map { |e| PdfObject(e, in_content_stream) }.join(' ') << "]"
        when Prawn::LiteralString
          obj = obj.gsub(/[\\\n\(\)]/) { |m| "\\#{m}" }
          "(#{obj})"
        when String
          obj = "\xFE\xFF" + obj.unpack("U*").pack("n*") unless in_content_stream
          "<" << obj.unpack("H*").first << ">"
        when Symbol
           if (obj = obj.to_s) =~ /\s/
             raise Prawn::Errors::FailedObjectConversion,
               "A PDF Name cannot contain whitespace"
           else
             "/" << obj
           end
        when Hash
          output = "<< "
          obj.each do |k,v|
            unless String === k || Symbol === k
              raise Prawn::Errors::FailedObjectConversion,
                "A PDF Dictionary must be keyed by names"
            end
            output << PdfObject(k.to_sym, in_content_stream) << " " <<
                      PdfObject(v, in_content_stream) << "\n"
          end
          output << ">>"
        when Prawn::Reference
          obj.to_s
        when Prawn::NameTree::Node
          PdfObject(obj.to_hash)
        when Prawn::NameTree::Value
          PdfObject(obj.name) + " " + PdfObject(obj.value)
        else
          raise Prawn::Errors::FailedObjectConversion,
            "This object cannot be serialized to PDF"
        end
      end