### Home Classes Methods

### In Files

- lib/prawn/security.rb

### Namespace

- CLASS PDF::Core::Reference
- CLASS PDF::Core::Stream

### Methods

- #EncryptedPdfObject

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# PDF::Core

### Public Instance Methods

EncryptedPdfObject(obj, key, id, gen, in_content_stream=false) click to toggle source

Like PdfObject, but returns an encrypted result if required. For direct objects, requires the object identifier and generation number from the indirect object referencing obj.

@private

    # File lib/prawn/security.rb, line 216
    def EncryptedPdfObject(obj, key, id, gen, in_content_stream=false)
      case obj
      when Array
        "[" << obj.map { |e|
            EncryptedPdfObject(e, key, id, gen, in_content_stream)
        }.join(' ') << "]"
      when LiteralString
        obj = ByteString.new(Prawn::Document::Security.encrypt_string(obj, key, id, gen)).gsub(/[\\\n\(\)]/) { |m| "\\#{m}" }
        "(#{obj})"
      when Time
        obj = obj.strftime("D:%Y%m%d%H%M%S%z").chop.chop + "'00'"
        obj = ByteString.new(Prawn::Document::Security.encrypt_string(obj, key, id, gen)).gsub(/[\\\n\(\)]/) { |m| "\\#{m}" }
        "(#{obj})"
      when String
        PdfObject(
          ByteString.new(
            Prawn::Document::Security.encrypt_string(obj, key, id, gen)),
          in_content_stream)
      when ::Hash
        output = "<< "
        obj.each do |k,v|
          unless String === k || Symbol === k
            raise PDF::Core::Errors::FailedObjectConversion,
              "A PDF Dictionary must be keyed by names"
          end
          output << PdfObject(k.to_sym, in_content_stream) << " " <<
                    EncryptedPdfObject(v, key, id, gen, in_content_stream) << "\n"
        end
        output << ">>"
      when NameTree::Value
        PdfObject(obj.name) + " " +
          EncryptedPdfObject(obj.value, key, id, gen, in_content_stream)
      when PDF::Core::OutlineRoot, PDF::Core::OutlineItem
        EncryptedPdfObject(obj.to_hash, key, id, gen, in_content_stream)
      else # delegate back to PdfObject
        PdfObject(obj, in_content_stream)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.