Class: Pdfrb::Model::Type::AlternateImage

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

Overview

AlternateImage (ISO 32000-2 §8.9.5, PDF 1.3+). An alternate image representation used when the primary image's color space isn't available (e.g. a DeviceGray fallback for a DeviceCMYK image on a monochrome printer).

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

#default_for_printing?Boolean

/DefaultForPrinting — optional, default false. When true, the alternate image is used for printing.

Returns:

  • (Boolean)


24
25
26
# File 'lib/pdfrb/model/type/alternate_image.rb', line 24

def default_for_printing?
  value[:DefaultForPrinting] == true
end

#image(document = nil) ⇒ Object

/Image — required indirect reference to the alternate image XObject.



15
16
17
18
19
20
# File 'lib/pdfrb/model/type/alternate_image.rb', line 15

def image(document = nil)
  ref = value[:Image]
  return nil unless ref && document

  ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
end

#optional_content(document = nil) ⇒ Object

/OC — optional optional-content group controlling the alternate's visibility (PDF 1.5+).



30
31
32
33
34
35
# File 'lib/pdfrb/model/type/alternate_image.rb', line 30

def optional_content(document = nil)
  ref = value[:OC]
  return nil unless ref && document

  ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
end