Class: Pdfrb::Model::Type::PagePieceInfo

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/page_piece_info.rb

Overview

Page-piece dictionary (s14.5). Per-page metadata recording application-specific private data. The dictionary hangs off a page's /PieceInfo key and is keyed by application name; each value carries /LastModified, /Private, and (optionally) an /ASFStream reference for a stream-encoded private payload.

Conforming readers MUST NOT interpret application-private data; it survives round-trips and incremental updates intact.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#application_nameObject

The application-name key (e.g. :Adobe, :Pdfrb). Multiple applications may each have their own entry in the same /PieceInfo dict.



18
19
20
# File 'lib/pdfrb/model/type/page_piece_info.rb', line 18

def application_name
  value.key?(:Application) ? value[:Application] : nil
end

#last_modifiedObject

/LastModified — PDF date string, parsed to a Time.



23
24
25
26
27
28
# File 'lib/pdfrb/model/type/page_piece_info.rb', line 23

def last_modified
  v = value[:LastModified]
  return nil unless v.is_a?(::String)

  Pdfrb::Model::Date.parse(v)
end

#last_modified=(time) ⇒ Object

Set the application's /LastModified to time. time is converted to a PDF date string.



38
39
40
# File 'lib/pdfrb/model/type/page_piece_info.rb', line 38

def last_modified=(time)
  value[:LastModified] = Pdfrb::Model::Date.format(time)
end

#merge_private!(hash) ⇒ Object

Merge hash into /Private. If /Private is absent, it is created from the hash.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pdfrb/model/type/page_piece_info.rb', line 44

def merge_private!(hash)
  existing = value[:Private]
  if existing.is_a?(Pdfrb::Model::Cos::Dictionary)
    existing.value.merge!(hash)
  elsif existing.is_a?(::Hash)
    existing.merge!(hash)
  else
    value[:Private] = hash
  end
  self
end

#private_dataObject

/Private — application-private dict. Untyped on purpose: the contents are app-defined.



32
33
34
# File 'lib/pdfrb/model/type/page_piece_info.rb', line 32

def private_data
  value[:Private]
end