def replace_text(self, *args):
     num_of_args = len(args)
     if num_of_args == 2:
         old_text = args[0]
         new_text = args[1]
     elif num_of_args == 3:
         worksheet_name = args[0]
         old_text = args[1]
         new_text = args[2]
     else:
         raise Exception("Wrong Numbers of Arguments")
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/cells/" + self.file_name
         if num_of_args == 3:
             str_uri += "/worksheet/" + worksheet_name
         str_uri += "/replaceText?oldValue=" + old_text + "&newValue=" + new_text
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def insert_watermark_image(self, file_name, image_filename, rotation_angle):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         if image_filename == "":
             raise Exception("Please Specify Image File Name")
         str_uri = (
             Product.base_product_uri
             + "/words/"
             + file_name
             + "/insertWatermarkImage?imageFile="
             + image_filename
             + "&rotationAngle="
             + str(rotation_angle)
         )
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(file_name)
             output_path = AsposeApp.output_location + file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def replace_text(self, file_name, old_value, new_value, is_match_case, is_match_whole_word):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         field_arr = {
             "OldValue": old_value,
             "NewValue": new_value,
             "IsMatchCase": str(is_match_case),
             "IsMatchWholeWord": str(is_match_whole_word),
         }
         json_arr = json.dumps(field_arr)
         str_uri = Product.base_product_uri + "/words/" + file_name + "/replaceText"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_arr)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(file_name)
             output_path = AsposeApp.output_location + file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def replace_text(self, old_text, new_text, is_regular_expression=False, page_number=0):
     try:
         if self.file_name == '':
             raise Exception('filename not specified')
         if old_text == '':
             raise Exception('old text not specified')
       
         if new_text == '':
             raise Exception('new text not specified')
         post_hash = { "OldValue" : old_text, "NewValue" : new_text, "Regex": "false" }
         json_data = json.dumps(post_hash)
         if page_number > 0:
             str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + '/replaceText'
         else:
             str_uri = Product.base_product_uri + "/pdf/" + self.file_name + '/replaceText'
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_data)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def insert_watermark_text(self, file_name, text, rotation_angle):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         field_array = {"Text": text, "RotationAngle": str(rotation_angle)}
         json_post_data = json.dumps(field_array)
         str_uri = Product.base_product_uri + "/words/" + file_name + "/insertWatermarkText"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_post_data)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(file_name)
             output_path = AsposeApp.output_location + file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def insert_page_number(self, file_name, alignment, text_format, is_top, set_page_number_on_first_page):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         field_arr = {"Format" : text_format , "Alignment" : alignment, "IsTop" : str(is_top), "SetPageNumberOnFirstPage" : str(set_page_number_on_first_page)}
         json_data = json.dumps(field_arr)
         str_uri = Product.base_product_uri + "/words/" + file_name + "/insertPageNumbers"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_data)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(file_name)
             output_path = AsposeApp.output_location + file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def execute_mail_merge(self, file_name, str_xml):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         if str_xml == "":
             raise Exception("Please Specify Xml String")
         str_uri = Product.base_product_uri + "/words/" + file_name + "/executeMailMerge"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "", str_xml)
         json_data = json.loads(response_stream)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(json_data["Document"]["FileName"].__str__())
             output_path = AsposeApp.output_location + file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def delete_chart(self, chart_index):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if self.worksheet_name == "":
             raise Exception("Please Specify Worksheet Name")
         
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/worksheets/" + self.worksheet_name + "/charts/" + str(chart_index)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "DELETE", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def add_chart(self, chart_type, upper_left_row, upper_left_column, lower_right_row, lower_right_column):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if self.worksheet_name == "":
             raise Exception("Please Specify Worksheet Name")
         
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/worksheets/" + self.worksheet_name + "/charts?chartType=" + chart_type + "&upperLeftRow=" + str(upper_left_row) + "&upperLeftColumn=" + str(upper_left_column) + "&lowerRightRow=" + str(lower_right_row) + "&lowerRightColumn=" + str(lower_right_column)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "PUT", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             output_stream = folder.get_file(self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def delete_all_slides(self,storage_type = None,storage_name = None, folder= None):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/slides"
         if folder is not None:
             str_uri += "?folder=" + folder
         if storage_name is not None:
             str_uri += "&storage=" + storage_name
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "DELETE", "JSON", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if(v_output == ""):
             folder = Folder()
             response_stream = folder.get_file(self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def append_document(self, append_docs=[], import_format_modes=[], source_folder=""):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if len(append_docs) != len(import_format_modes):
             raise Exception("Please specify complete documents and import format modes")
         str_uri = Product.base_product_uri + "/words/" + self.file_name + "/appendDocument"
         signed_uri = Utils.sign(Utils(), str_uri)
         
         post_array = []
         i = 0
         for val in append_docs:
             d= dict()
             if source_folder != "":
                 href = source_folder +"\\"+val
             else:
                 href= val
             d.update({ "Href" : href, "ImportFormatMode" : import_format_modes[i]})
             post_array.append(d);
             i = i+1
         data = {"DocumentEntries" : post_array}
         
         json_data = json.dumps(data)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_data)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             folder = Folder()
             uri = ""
             if source_folder is not "":
                 uri = "/" 
             output_stream = folder.get_file(uri + self.file_name)
             output_path = AsposeApp.output_location + self.file_name
             Utils.save_file(Utils(), output_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise