Class: PdflibWrapper::External::Image::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/pdflib_wrapper/external/image/document.rb

Constant Summary collapse

VALID_IMAGE_TYPES =
%Q{bmp ccitt gif jbig2 jpeg jpeg2000 png raw tiff}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf, filepath, opts = {}) ⇒ Document



7
8
9
10
11
12
13
14
15
16
# File 'lib/pdflib_wrapper/external/image/document.rb', line 7

def initialize(pdf, filepath, opts={})
  #TODO: support opts
  if opts[:image_type].nil? || !opts[:image_type].kind_of?(String) || opts[:image_type].empty? || !VALID_IMAGE_TYPES.include?(opts[:image_type])
    @image_type = "auto"
  else
    @image_type = opts[:image_type]
  end
  @pdf = pdf
  @document = @pdf.load_image(@image_type, filepath, OptionListMapper.create_options('', [], [], opts) )
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



6
7
8
# File 'lib/pdflib_wrapper/external/image/document.rb', line 6

def document
  @document
end

#image_typeObject

Returns the value of attribute image_type.



6
7
8
# File 'lib/pdflib_wrapper/external/image/document.rb', line 6

def image_type
  @image_type
end

Instance Method Details

#closeObject



18
19
20
21
# File 'lib/pdflib_wrapper/external/image/document.rb', line 18

def close
  #TODO: support opts
  @pdf.close_image(@document)
end