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 save(self, codeText, symbology, imageFormat, xResolution, yResolution, xDimension, yDimension):
     strURI = Product.base_product_uri + "/barcode/generate?text=" + codeText + "&type=" + str(symbology) + "&format=" + imageFormat
     if xResolution <= 0:
         strURI += ""
     else:
         strURI += "&resolutionX=" + str(xResolution)
     if yResolution <= 0:
         strURI += ""
     else:
         strURI += "&resolutionY=" + str(yResolution)
     if xDimension <= 0:
         strURI += ""
     else:
         strURI += "&dimensionX=" + str(xDimension)
     if yDimension <= 0:
         strURI += ""
     else:
         strURI += "&dimensionY=" + str(yDimension)
     try:
         signedURI = Utils.sign(Utils(), strURI)
         response = Utils.process_command(Utils(), signedURI, "GET", "", "")
         v_output = Utils.validate_output(self, response)
         if(v_output == ""):
             output_path = AsposeApp.output_location + "barcode" + str(symbology) + "." + imageFormat
             Utils.save_file(self, response, output_path)
             return output_path
     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 convert_local_file(self, input_file, output_filename, output_format):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if input_file == "":
             raise Exception("Please Specify Input File Along With Path")
         if output_filename == "":
             raise Exception("Please Specify Output File Name")
         if output_format == "":
             raise Exception("Please Specify Output Format")
         str_uri = Product.base_product_uri + "/pdf/convert?format=" + output_format
         if os.path.exists(input_file) == False:
             raise Exception("Input File Does not Exists")
         signed_uri = Utils.sign(Utils(), str_uri)
         
         response_stream = Utils.upload_file_binary(Utils(), signed_uri, input_file)
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             if self.save_format == "html":
                 save_format = "zip"
             else:
                 save_format = output_format
             if output_filename == "":
                 output_path = AsposeApp.output_location + Utils.get_filename(Utils(), input_file) + "." + save_format
             else:
                 output_path = AsposeApp.output_location + output_filename + "." + save_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 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 convert_local_file(self, input_filename, output_filename, output_format):
     try:
         if input_filename == "":
             raise Exception("Please Specify Local File Name")
         if output_filename == "":
             raise Exception("Please Specify Output File Name")
         if output_format == "":
             raise Exception("Please Specify Output Format")
         str_uri = Product.base_product_uri + "/words/convert?format=" + output_format
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.upload_file_binary(Utils(), signed_uri, input_filename, "xml")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             if output_format == "html":
                 save_format = "zip"
             else:
                 save_format = output_format
             if output_filename == "":
                 output_path = AsposeApp.output_location + Utils.get_filename(Utils(), input_filename) + "." + save_format
             else:
                 output_path = AsposeApp.output_location + output_filename + "." + save_format
             Utils.save_file(Utils(), response_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 get_default_size(self, page_number, image_index, image_format):
     try:
         if self.file_name == "":
             raise Exception("Please Specify Pdf File")
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + "/images/" + str(image_index) + "?format=" + image_format
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_" + str(image_index) + "." + image_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def convert(self):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/words/" + self.file_name + "?format=" + self.save_format
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if(v_output == ""):
             output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "." + self.save_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def get_autoshape(self, worksheet_name, autoshape_index, image_format):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/worksheets/" + worksheet_name + "/autoshapes/" + str(autoshape_index) + "?format=" + image_format
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_" + worksheet_name + "." + image_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise 
 def convert_to_image_by_size(self, page_number, image_format, width, height):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + "?format=" + image_format + "&width=" + str(width) + "&height" + str(height)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_" + str(page_number) + "." + image_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def get_image_data(self, index, render_format):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/words/" + self.file_name + "/drawingObjects/" + str(index) + "/ImageData"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_" + str(index) + "." + render_format
             Utils.save_file(Utils(), response_stream, output_path)
             return output_path
         else:
             return v_output
     except:
         raise
 def download_attachment(self, attachment_index):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         file_information = self.get_attachment(attachment_index)
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/attachments/" + str(attachment_index) + "/download"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if v_output == "":
             output_path = AsposeApp.output_location + file_information["Name"]
             Utils.save_file(Utils, response_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 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_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 save_slide_as(self, slide_number, output_path, save_format):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if output_path == "":
             raise Exception("Please Specify Output Path")
         if save_format == "":
             raise Exception("Please Specify Save Format")
         if slide_number == "" or slide_number == 0:
             raise Exception("Please Specify Slide Number")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/slides/" + str(slide_number) + "?format=" + save_format
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if(v_output == ""):
             Utils.save_file(Utils(), response_stream, output_path + Utils.get_filename(Utils(), self.file_name) + "_" + str(slide_number) + "." + save_format)
             return True
         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_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
 def get_drawing_object(self, object_uri, output_path):
     
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if object_uri == "":
             raise Exception("Please Specify Object URI")
         if output_path == "":
             raise Exception("Please Specify Output Path")
         
         url_arr = object_uri.split("/")
         object_index = self.end(url_arr) 
         str_uri = object_uri
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             if json_data["DrawingObject"]["ImageDataLink"] != "":
                 str_uri = str_uri + "/imageData"
                 output_path = output_path + "\\DrawingObject_" + str(object_index) + ".jpeg"
             elif json_data["DrawingObject"]["OLEDataLink"] != "":
                 str_uri = str_uri + "/oleData"
                 output_path = output_path + "\\DrawingObject_" + str(object_index) + ".xlsx"
             else:
                 str_uri = str_uri + "?format=jpeg"
                 output_path = output_path + "\\DrawingObject_" + str(object_index) + ".jpeg"
             signed_uri = Utils.sign(Utils(), str_uri)
             response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
             v_output = Utils.validate_output(Utils(), response_stream)
             if v_output == "":
                 Utils.save_file(Utils(), response_stream, output_path)
                 return output_path
             else:
                 return v_output
         else:
             return False
     except:
         raise
 def save_as(self, output_path, save_format,storage_type = None,storage_name = None,folder=None):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         if output_path == "":
             raise Exception("Please Specify Output Path")
         if save_format == "":
             raise Exception("Please Specify Save Format")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "?format=" + save_format
         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, "GET", "", "")
         v_output = Utils.validate_output(Utils(), response_stream)
         if(v_output == ""):
             Utils.save_file(Utils(), response_stream, output_path + Utils.get_filename(Utils(), self.file_name) + "." + save_format)
             return True
         else:
             return v_output
     except:
         raise