Class: PDF::Writer::Object::Contents

### Home Classes Methods

### In Files

- lib/pdf/writer/object/contents.rb

### Parent

PDF::Writer::Object

### Methods

- ::new
- #<<
- #add
- #each
- #size
- #to_s

### Files

- ChangeLog

### Class/Module Index

Quicksearch

- PDF
- PDF::Charts
- PDF::Charts::StdDev
- PDF::Charts::StdDev::Label
- PDF::Charts::StdDev::Marker
- PDF::Charts::StdDev::Scale
- PDF::Math
- PDF::QuickRef
- PDF::SimpleTable
- PDF::SimpleTable::Column
- PDF::SimpleTable::Column::Heading
- PDF::TechBook
- PDF::TechBook::TagTocDots
- PDF::TechBook::TagXref
- PDF::Writer
- PDF::Writer::ARC4
- PDF::Writer::Complex
- PDF::Writer::External
- PDF::Writer::FontMetrics
- PDF::Writer::Graphics
- PDF::Writer::Graphics::ImageInfo
- PDF::Writer::Graphics::ImageInfo::Formats
- PDF::Writer::Graphics::ImageInfo::Type
- PDF::Writer::Lang
- PDF::Writer::Lang::EN
- PDF::Writer::OHash
- PDF::Writer::Object
- PDF::Writer::Object::Action
- PDF::Writer::Object::Annotation
- PDF::Writer::Object::Catalog
- PDF::Writer::Object::Contents
- PDF::Writer::Object::Destination
- PDF::Writer::Object::Encryption
- PDF::Writer::Object::Font
- PDF::Writer::Object::FontDescriptor
- PDF::Writer::Object::FontEncoding
- PDF::Writer::Object::Info
- PDF::Writer::Object::Outline
- PDF::Writer::Object::Outlines
- PDF::Writer::Object::Pages
- PDF::Writer::Object::Procset
- PDF::Writer::Object::ViewerPreferences
- PDF::Writer::OffsetReader
- PDF::Writer::PolygonPoint
- PDF::Writer::State
- PDF::Writer::StateStack
- PDF::Writer::StrokeStyle

No matching classes.

# PDF::Writer::Object::Contents

The contents objects hold all of the content which appears on pages

### Attributes

data[RW]
on_page[R]

### Public Class Methods

new(parent, page = nil) click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 13
    def initialize(parent, page = nil)
      super(parent)

      @data = ""
      @info = {}
      @raw = false
      @on_page = nil

      if page.kind_of?(PDF::Writer::Object::Page)
        @on_page = page
      elsif page == :raw
        @raw = true
      end
    end

### Public Instance Methods

<<(v) click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 39
    def <<(v)
      raise TypeError unless v.kind_of?(PDF::Writer::Object) or v.kind_of?(String)
      @data << v
    end

add(a) click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 44
    def add(a)
      a.each { |k, v| @info[k] = v }
    end

each() click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 35
    def each
      @contents.each { |c| yield c }
    end

size() click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 31
    def size
      @data.size
    end

to_s() click to toggle source

    # File lib/pdf/writer/object/contents.rb, line 48
    def to_s
      tmp = @data.dup
      res = "\n#{@oid} 0 obj\n"
      if @raw
        res << tmp
      else
        res << "<<"
        if PDF::Writer::Compression and @parent.compressed?
          res << " /Filter /FlateDecode"
          tmp = Zlib::Deflate.deflate(tmp)
        end
        @info.each { |k, v| res << "\n/#{k} #{v}" }
        res << "\n/Length #{tmp.size} >>\nstream\n#{tmp}\nendstream"
      end
      res << "\nendobj\n"
      res
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.