Class: Aspose::Cloud::Slides::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/Slides/converter.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Converter

Returns a new instance of Converter.



7
8
9
# File 'lib/Slides/converter.rb', line 7

def initialize filename
  @filename = filename
end

Instance Method Details

#convert(save_format, slide_number, storage_name = '', folder = '') ⇒ Object

convert a document to SaveFormat



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/Slides/converter.rb', line 65

def convert save_format,slide_number, storage_name='', folder=''
  begin

    if @filename == ''
      raise 'filename not specified'
    end                

    if save_format == ''
      raise 'save format not specified'
    end
        
    if(storage_name.empty? == true)       
      str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + save_format
    else
      str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + save_format + '&storage=' + storage_name + '&folder=' + folder
    end

    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})  

    valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

    if valid_output == ''
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + save_format
      Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
      return ''
    else
      return valid_output
    end


  rescue Exception=>e
    print e
  end
end

#convert_to_image(slide_number, image_format, width, height) ⇒ Object

Saves a particular slide into various formats with specified width and height

@param number slide_number
@param string image_format
@param number width
@param number height


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/Slides/converter.rb', line 18

def convert_to_image slide_number, image_format, width, height
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if slide_number == ''
      raise 'slide number not specified'
    end

    if image_format == ''
      raise 'image format not specified'
    end

    if width == ''
      raise 'width not specified'
    end

    if height == ''
      raise 'height not specified'
    end
        
    str_uri = $product_uri + '/slides/' + @filename + '/slides/' + slide_number.to_s + '?format=' + image_format +'&width=' + width.to_s + '&height=' + height.to_s

    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})  

    valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

    if valid_output == ''
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
      return ''
    else
      return valid_output
    end


  rescue Exception=>e
    print e
  end
end