Method: Aspose::Cloud::Words::Extractor#get_drawing_object

Defined in:
lib/Words/extractor.rb

#get_drawing_object(object_uri, output_path) ⇒ Object

Get the drawing object from document

@param string object_uri
@param string output_path


210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/Words/extractor.rb', line 210

def get_drawing_object object_uri, output_path
      
  begin

    if @filename == ''
      raise 'Base file not specified.'
    end

    if object_uri == ''
      raise 'Object URI not specified.'
    end

    if output_path == ''
      raise 'Output path not specified.'
    end

    url_arr = object_uri.split('/')
    object_index = url_arr.at(-1)        

    str_uri = object_uri
    signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    if(stream_hash['Code'] == 200)
  
      if stream_hash['DrawingObject']['ImageDataLink'] != ''
        str_uri = str_uri + '/imageData'
        output_path = output_path + '\\DrawingObject_' + object_index.to_s + '.jpeg'
      elsif stream_hash['DrawingObject']['OLEDataLink'] != ''
        str_uri = str_uri + '/oleData'
        output_path = output_path + '\\DrawingObject_' + object_index.to_s + '.xlsx'
      else
        str_uri = str_uri + '?format=jpeg'
        output_path = output_path + '\\DrawingObject_' + object_index.to_s + '.jpeg'
      end
  
      signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  
      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) + '_' + index.to_s + '.' + render_format
        Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
        return output_path
      else
        return valid_output
      end
  
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end