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 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 get_shapes(self, slide_number,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/" + str(slide_number) + "/shapes"
         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", "", "")
         json_data = json.loads(response_stream)
         shapes = {}
         if json_data["Code"] == 200:
             shape = {}
             for json_data["ShapeList"]["Links"] in shape:
                 signed_uri = Utils.sign(Utils(), shape["Uri"]["Href"])
                 response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
                 data = json.loads(response_stream)
                 shapes = data
             return shapes
         else:
             return json_data
     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, *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 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):
         old_text = args[0]
         new_text = args[1]
         slide_number = args[2]
     else:
         raise Exception("Invalid Numbers of Arguments")
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name
         if num_of_args == 3:
             str_uri += "/slides/" + str(slide_number)
         str_uri += "/replaceText?oldValue=" + old_text + "&newValue=" + new_text + "&ignoreCase=true"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "JSON", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return str(json_data["Matches"]) + " Found And Replaced"
         else:
             return False
     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 get_image_count(self, page_number):
     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"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return len(json_data["Images"]["List"])
     except:
         raise
 def is_child_bookmark(self, bookmark_index):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/bookmarks/" + str(bookmark_index)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Bookmark"]
     except:
         raise
 def get_child_bookmark_count(self, parent_index):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/bookmarks/" + str(parent_index) + "/bookmarks"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return len(json_data["Bookmarks"]["List"])
     except:
         raise
 def get_annotation(self, page_number, annotation_index):
     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) + "/annotations/" + str(annotation_index)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Annotation"]
     except:
         raise
 def get_attachment(self, attachment_index):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/attachments/" + str(attachment_index)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Attachments"]
     except:
         raise
Пример #13
0
 def get_mailmerge_field_names(self, file_name):
     try:
         if file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/words/" + file_name + "/mailMergeFieldNames"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET" , "", "")
         json_data = json.loads(response_stream)
         return json_data["FieldNames"]
     except:
         raise
 def create_empty_workbook(self):
     try:
         str_uri = Product.base_product_uri + "/cells/" + self.file_name
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "PUT", "", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return json_data
         else:
             return False
     except:
         raise
 def convert(self):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "?format=" + self.save_format
         signed_uri = Utils.sign(self, str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         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
     except:
         raise
 def convert_to_image_by_size(self, slide_number, image_format, width, height):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/slides/" + str(slide_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", "", "")
         output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_slide_" + str(slide_number) + "." + image_format
         Utils.save_file(Utils(), response_stream, output_path);
         return output_path
     except:
         raise
 def get_cells_count(self, off_set, count):
     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 + "/cells?offset=" + str(off_set) + "&count=" + str(count)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Cells"]["CellCount"]
     except:
         raise
 def get_autoshapes_count(self):
     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 + "/autoshapes"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return len(json_data["AutoShapes"]["AutoShapeList"])
     except:
         raise
 def get_column(self, column_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 + "/cells/columns/" + str(column_index)
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Column"]
     except:
         raise
 def get_cell_style(self, cell_name):
     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 + "/cells/" + cell_name + "/style"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data
     except:
         raise
 def get_mergedcell_count(self):
     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 + "/mergedCells"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["MergedCells"]["Count"]
     except:
         raise
 def calculate_formula(self, formula):
     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 + "/formulaResult?formula=" + formula
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Value"]["Value"]
     except:
         raise
 def get_document_info(self):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/words/" + self.file_name
         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:
             return json_data["Document"]
         else:
             return False
     except:
         raise
 def get_border(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) + "/chartArea/border"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["Line"]
     except:
         raise
 def ReadR(self, remote_image_name, remote_folder_name, barcode_read_type):
     try:
         if self.filename == "":
             raise Exception("Please Specify File Name")
         strURI = self.URIBuilder(remote_image_name, remote_folder_name, barcode_read_type)
         signedURI = Utils.sign(Utils(), strURI)
         response_stream = Utils.process_command(Utils(), signedURI, "GET", "JSON", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return json_data["Barcodes"]
         else:
             return False
     except:
         raise
 def create_workbook_from_template(self, template_filename):
     try:
         if template_filename == "":
             raise Exception("Please Specify Template File Name")
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "?templatefile=" + template_filename
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "PUT", "", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return json_data
         else:
             return False
     except:
         raise
 def delete_document_property(self, property_name):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/documentProperties/" + property_name
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "DELETE", "", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return True
         else:
             return False
     except:
         raise
 def process_smartmarker(self, data_file):
     try:
         if data_file == "":
             raise Exception("Please Specify Template Data File")
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/smartmarker?xmlFile=" + data_file
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "POST", "", "")
         json_data = json.loads(response_stream)
         if json_data["Code"] == 200:
             return json_data
         else:
             return False
     except:
         raise
 def get_names_count(self):
     try:
         if self.file_name == "":
             raise Exception("Please Specify File Name")
         str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/names"
         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:
             return len(json_data["Names"])
         else:
             return False
     except:
         raise
 def get_text_format(self, page_number, fragment_number, segment_number=None):
     try:
         if self.file_name == "":
             raise Exception("Please Specify Pdf File Name") 
         str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + "/fragments/" + str(fragment_number)
         if segment_number is not None:
             str_uri += "/segments/" + str(segment_number)
         str_uri += "/textformat"
         signed_uri = Utils.sign(Utils(), str_uri)
         response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
         json_data = json.loads(response_stream)
         return json_data["TextFormat"]
     except:
         raise