/// <summary> /// Page's replace text method. /// </summary> /// <param name="name">The document name.</param> /// <param name="pageNumber">The page number.</param> /// <param name="folder">The document folder.</param> /// <param name="storage">The document storage.</param> public PageReplaceTextResponse ReplaceText(string name, int pageNumber, string folder, TextReplace textReplace, string storage = "") { // POST pdf/{name}/pages/{pageNumber}/replaceText?appSid={appSid}&storage={storage}&folder={folder} string apiUrl = string.Format(@"pdf/{0}/pages/{1}/replaceText?storage={2}&folder={3}", name, pageNumber, storage, folder); JObject jObject = JObject.Parse(ServiceController.Post(apiUrl, AppSid, AppKey, JsonConvert.SerializeObject(textReplace))); PageReplaceTextResponse pageReplaceTextResponse = jObject.ToObject<PageReplaceTextResponse>(); return pageReplaceTextResponse; }
public void Pdf_TextReplace_Tests() { try { storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-textReplace.pdf"); TextReplace textReplace = new TextReplace("Aspose", "Aspose Pty Ltd.", true); DocumentReplaceTextResponse documentReplaceTextResponse = pdfService.TextReplace.ReplaceText("pdf-textReplace.pdf", Utils.CloudStorage_Output_Folder, textReplace); storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-textReplace.pdf", Utils.Local_Output_Path + "/pdf-textReplace.pdf"); //------------------------------ storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-textReplace2.pdf"); TextReplace textReplace2 = new TextReplace("Aspose", "Aspose Pty Ltd.", true); PageReplaceTextResponse pageTextReplaceResponse = pdfService.TextReplace.ReplaceText("pdf-textReplace2.pdf", 1, Utils.CloudStorage_Output_Folder, textReplace2); storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-textReplace2.pdf", Utils.Local_Output_Path + "/pdf-textReplace2.pdf"); //======================================== storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-textReplaceList.pdf"); TextReplaceList textReplaceList = new TextReplaceList(); textReplaceList.TextReplaces.Add(new TextReplace("Aspose", "Aspose Pty Ltd.", true)); textReplaceList.TextReplaces.Add(new TextReplace("MS Office", "Microsoft Office", true)); DocumentReplaceTextResponse textReplaceResponse = pdfService.TextReplace.ReplaceTextList("pdf-textReplaceList.pdf", Utils.CloudStorage_Output_Folder, textReplaceList); storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-textReplaceList.pdf", Utils.Local_Output_Path + "/pdf-textReplaceList.pdf"); //------------------------------------------------- storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-textReplaceList2.pdf"); TextReplaceList textReplaceList2 = new TextReplaceList(); textReplaceList2.TextReplaces.Add(new TextReplace("Aspose", "Aspose Pty Ltd.", true)); textReplaceList2.TextReplaces.Add(new TextReplace("MS Office", "Microsoft Office", true)); PageReplaceTextResponse pageTextReplaceResponse2 = pdfService.TextReplace.ReplaceTextList("pdf-textReplaceList2.pdf", 1, Utils.CloudStorage_Output_Folder, textReplaceList2); storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-textReplaceList2.pdf", Utils.Local_Output_Path + "/pdf-textReplaceList2.pdf"); } catch (Exception ex) { Assert.Fail(ex.Message); } }