/ Published in: C#
The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
AsposeApp.AppSID = "77***********************************"; AsposeApp.AppKey = "9a*******************************"; //build URI stringstrURI = "http://api.aspose.com/v1.1/pdf/test.pdf/replaceTextList"; //sign URI stringsignedURI = Utils.Sign(strURI); //build JSON to post textReplace1.OldValue = "[!firm!]"; textReplace1.NewValue = "Aspose"; textReplace1.Regex = "false"; //build JSON to post textReplace2.OldValue = "[!client!]"; textReplace2.NewValue = "Mark"; textReplace2.Regex = "false"; stringstrJSON = JsonConvert.SerializeObject(textReplaces); Console.Write(strJSON); Utils.ProcessCommand(signedURI, "POST", strJSON); //build URI strURI = "http://api.aspose.com/v1.1/storage/file/test.pdf"; //sign URI signedURI = Utils.Sign(strURI); Stream responseStream = Utils.ProcessCommand(signedURI, "GET"); using (Stream fileStream = System.IO.File.OpenWrite(@"test.pdf")) { Utils.CopyStream(responseStream, fileStream); } responseStream.Close(); //Following are required classes public class MultipleTextReplaces { publicTextReplace[] TextReplaces { get; set; } } public class TextReplace { publicTextReplace() { } public string OldValue { get; set; } public string NewValue { get; set; } public string Regex { get; set; } }
URL: http://www.aspose.com/docs/display/pdfcloud/Replace+Multiple+Texts+in+a+PDF