Sha256: bf41d22f2442bdac08fcb0c0a193dc92645e1f29f7674669c66677645ffdc7b5

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

#--
# PDF::Writer for Ruby.
#   http://rubyforge.org/projects/ruby-pdf/
#   Copyright 2003 - 2005 Austin Ziegler.
#
#   Licensed under a MIT-style licence. See LICENCE in the main distribution
#   for full licensing information.
#
# $Id: info.rb 177 2007-11-26 16:06:58Z sandal $
#++
  # Define the document information -- metadata.
class PDF::Writer::Object::Info < PDF::Writer::Object
  Info = %w{CreationDate Creator Title Author Subject Keywords ModDate Trapped Producer}
  def initialize(parent)
    super(parent)

    @parent.instance_variable_set('@info', self)
    @creationdate = Time.now

    @creator  = File.basename($0)
    @producer = "PDF::Writer for Ruby"
    @title    = nil
    @author   = nil
    @subject  = nil
    @keywords = nil
    @moddate  = nil
    @trapped  = nil
  end

  Info.each do |i|
    attr_accessor i.downcase.intern
  end

  def to_s
    res = "\n#{@oid} 0 obj\n<<\n"
    Info.each do |i|
      v = __send__("#{i.downcase}".intern)
      next if v.nil?
      res << "/#{i} ("
      if v.kind_of?(Time)
        s = "D:%04d%02d%02d%02d%02d"
        v = v.utc
        v = s % [ v.year, v.month, v.day, v.hour, v.min ]
      end

      res << PDF::Writer.escape(v)
      res << ")\n"
    end
    res << ">>\nendobj"
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
mack-pdf_writer-0.8.2 lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/info.rb
mack-pdf_writer-0.8.3 lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/info.rb
mack-pdf_writer-0.8.3.1 lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/info.rb
pdf-writer-1.1.5 lib/pdf/writer/object/info.rb
pdf-writer-1.1.6 lib/pdf/writer/object/info.rb
pdf-writer-1.1.8 lib/pdf/writer/object/info.rb
pdf-writer-1.1.7 lib/pdf/writer/object/info.rb