Class: PDF::Reader::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/resources.rb

Overview

mixin for common methods in Page and FormXobjects

Instance Method Summary collapse

Constructor Details

#initialize(objects, resources) ⇒ Resources

Returns a new instance of Resources.



12
13
14
15
# File 'lib/pdf/reader/resources.rb', line 12

def initialize(objects, resources)
  @objects = objects
  @resources = resources
end

Instance Method Details

#color_spacesObject

Returns a Hash of color spaces that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


23
24
25
# File 'lib/pdf/reader/resources.rb', line 23

def color_spaces
  @objects.deref_hash!(@resources[:ColorSpace]) || {}
end

#fontsObject

Returns a Hash of fonts that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


33
34
35
# File 'lib/pdf/reader/resources.rb', line 33

def fonts
  @objects.deref_hash!(@resources[:Font]) || {}
end

#graphic_statesObject

Returns a Hash of external graphic states that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


44
45
46
# File 'lib/pdf/reader/resources.rb', line 44

def graphic_states
  @objects.deref_hash!(@resources[:ExtGState]) || {}
end

#patternsObject

Returns a Hash of patterns that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


54
55
56
# File 'lib/pdf/reader/resources.rb', line 54

def patterns
  @objects.deref_hash!(@resources[:Pattern]) || {}
end

#procedure_setsObject

Returns an Array of procedure sets that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


64
65
66
# File 'lib/pdf/reader/resources.rb', line 64

def procedure_sets
  @objects.deref_array!(@resources[:ProcSet]) || []
end

#propertiesObject

Returns a Hash of properties sets that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


74
75
76
# File 'lib/pdf/reader/resources.rb', line 74

def properties
  @objects.deref_hash!(@resources[:Properties]) || {}
end

#shadingsObject

Returns a Hash of shadings that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


84
85
86
# File 'lib/pdf/reader/resources.rb', line 84

def shadings
  @objects.deref_hash!(@resources[:Shading]) || {}
end

#xobjectsObject

Returns a Hash of XObjects that are available to this page

NOTE: this method de-serialise objects from the underlying PDF

with no caching. You will want to cache the results instead
of calling it over and over.


94
95
96
97
# File 'lib/pdf/reader/resources.rb', line 94

def xobjects
  dict = @objects.deref_hash!(@resources[:XObject]) || {}
  TypeCheck.cast_to_pdf_dict_with_stream_values!(dict)
end