class Aspose::Cloud::Words::Document

Public Class Methods

new(filename) click to toggle source
# File lib/Words/document.rb, line 8
def initialize(filename)
  @filename = filename
end

Public Instance Methods

append_document(append_docs, import_format_modes, source_folder) click to toggle source
Appends a list of documents to this one.
@param string append_docs
@param import_format_modes
@param source_folder

end

# File lib/Words/document.rb, line 19
def append_document append_docs, import_format_modes, source_folder
  begin

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

    if append_docs.length != import_format_modes.length
      raise 'Please specify complete documents and import format modes.'
    end

    str_uri = $product_uri + '/words/' + @filename + '/appendDocument'
    signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    post_hash = Hash['DocumentEntries',append_docs];                                
    json_data = post_hash.to_json

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

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

    if valid_output == ''                              
      folder = Aspose::Cloud::AsposeStorage::Folder.new
      if source_folder == ''
        output_stream = folder.get_file(@filename)
      else
        output_stream = folder.get_file( source_folder + '/' + @filename)
      end
      output_path = $out_put_location + @filename
      Aspose::Cloud::Common::Utils.save_file(output_stream,output_path)
      return ''
    else
      return valid_output
    end


  rescue Exception=>e
    print e
  end
end
convert_local_file(input_file,output_filename,output_format) click to toggle source

Convert Word to different file format without using storage @param string inputFile @param string outputFilename @param string outputFormat

# File lib/Words/document.rb, line 245
def convert_local_file input_file,output_filename,output_format
  begin

    if input_file == ''
      raise('input file not specified')
    end                

    if output_filename == ''
      raise('output file not specified')
    end

    if output_format == ''
      raise('output format not specified')
    end

    str_uri = $product_uri + '/words/convert?format=' + output_format
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, str_signed_uri)                

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

    if valid_output == ''
  
      if output_format == 'html'
        saveformat = 'zip'
      else
        saveformat = output_format
      end
  
      if output_filename == ''
        output_filename = Utils::get_filename(input_file) + '.' + saveformat
      end
  
      output_path = $out_put_location + output_filename
      Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
      return ''
    else
      return valid_output
    end

  rescue Exception=>e
    print e        
  end      
end
delete_property(property_name) click to toggle source
Delete a document property
@param string property_name

end

# File lib/Words/document.rb, line 176
def delete_property property_name
      
  begin

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

    if property_name == ''
      raise 'Property name not specified.'
    end

    str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name
    signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

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

    stream_hash = JSON.parse(response_stream)

    if(stream_hash['Code'] == 200)
      return true
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end
get_document_info() click to toggle source
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties

end

# File lib/Words/document.rb, line 64
def get_document_info
      
  begin

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

    str_uri = $product_uri + '/words/' + @filename
    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)
      return stream_hash['Document']
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end
get_properties() click to toggle source
Get Document's properties

end

# File lib/Words/document.rb, line 211
def get_properties
      
  begin

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

    str_uri = $product_uri + '/words/' + @filename + '/documentProperties'
    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)
      return stream_hash['DocumentProperties']['List']
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end
get_property(property_name) click to toggle source
Get Resource Properties information like document source format, IsEncrypted, IsSigned and document properties
@param string property_name

end

# File lib/Words/document.rb, line 96
def get_property property_name
      
  begin

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

    if property_name == ''
      raise 'Property name not specified.'
    end

    str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name
    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)
      return stream_hash['DocumentProperty']
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end
set_property(property_name, property_value) click to toggle source
Set document property
@param string property_name
@param string property_value

end

# File lib/Words/document.rb, line 133
def set_property property_name, property_value
      
  begin

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

    if property_name == ''
      raise 'Property name not specified.'
    end

    if property_value == ''
      raise 'Property value not specified.'
    end

    post_hash = { 'Value' => property_value}
    json_data = post_hash.to_json  

    str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name
    signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

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

    stream_hash = JSON.parse(response_stream)

    if(stream_hash['Code'] == 200)
      return stream_hash['DocumentProperty']
    else
      return false
    end

  rescue Exception=>e
    print e
  end
      
end