public static void Run() { // ExStart:1 PdfApi pdfApi = new PdfApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "test.pdf"; string storage = null; string folder = null; Com.Aspose.PDF.Model.TextReplace body = new Com.Aspose.PDF.Model.TextReplace(); body.OldValue = "Sample PDF"; body.NewValue = "This is the new test added by IA"; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.PDF Cloud SDK API to replace pdf text DocumentTextReplaceResponse apiResponse = pdfApi.PostDocumentReplaceText(fileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Replace PDF Document Text, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 PdfApi pdfApi = new PdfApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "sample-input.pdf"; String storage = ""; String folder = ""; TextReplaceListRequest body = new TextReplaceListRequest(); TextReplace tr1 = new TextReplace(); tr1.OldValue = "Sample"; tr1.NewValue = "Aspose Sample"; TextReplace tr2 = new TextReplace(); tr2.OldValue = "PDF"; tr2.NewValue = "PDF Document"; body.TextReplaces = new List <TextReplace> { tr1, tr2 }; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.PDF Cloud SDK API to replace multiple text in PDF DocumentTextReplaceResponse apiResponse = pdfApi.PostDocumentReplaceTextList(fileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Replace Multiple Texts in a PDF, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }