public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; String storage = "dropboxstorage"; String folder = null; ReplaceTextRequest body = new ReplaceTextRequest(); body.OldValue = "aspose"; body.NewValue = "aspose.com"; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to replace text in a document using third party storage Com.Aspose.Words.Model.ReplaceTextResponse apiResponse = wordsApi.PostReplaceText(fileName, fileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Text replaced successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; int index = 0; int runIndex = 0; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get font informations of a run from word document FontResponse apiResponse = wordsApi.GetDocumentParagraphRunFont(fileName, index, runIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Font runFont = apiResponse.Font; Console.WriteLine("Font Name : " + runFont.Name); Console.WriteLine("Style : " + runFont.StyleName); Console.WriteLine("Size : " + runFont.Size); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; String propertyName = "AsposeAuthor"; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to remove particular document property SaaSposeResponse apiResponse = wordsApi.DeleteDocumentProperty(fileName, propertyName, fileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("The document property has been removed successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "SampleWordDocument.docx"; int sectionIndex = 0; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get specific section SectionResponse apiResponse = wordsApi.GetSection(fileName, sectionIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine(apiResponse.Section.link.Href); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "sample_EmbeddedOLE.docx"; int objectIndex = 0; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get OLE data from image object ResponseMessage apiResponse = wordsApi.GetDocumentDrawingObjectOleData(fileName, objectIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Got the OLE Drawing Object from Document successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; String storage = "dropboxstorage"; String folder = null; PageNumber body = new PageNumber(); body.Format = "{PAGE} of {NUMPAGES}"; body.Alignment = "center"; try { // Upload the file storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to insert page number using third party storage DocumentResponse apiResponse = wordsApi.PostInsertPageNumbers(fileName, fileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Page Number Field has been inserted successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleBlankWatermarkDocument.docx"; String destFileName = "updated-" + fileName; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to remove watermark from document DocumentResponse apiResponse = wordsApi.DeleteDocumentWatermark(fileName, destFileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Watermark is removed successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "SampleWordDocument.docx"; int index = 1; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get paragraph from word document ParagraphResponse apiResponse = wordsApi.GetDocumentParagraph(fileName, index, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Com.Aspose.Words.Model.Paragraph docParagraph = apiResponse.Paragraph; Console.WriteLine("NoteId : " + docParagraph.NodeId); Console.WriteLine("Link : " + docParagraph.link.Href); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set input file name String docFileName = "SampleWordDocument.docx"; String fileName = docFileName; String storage = null; String folder = null; try { // Upload file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to accept all tracking changes in document RevisionsModificationResponse apiResponse = wordsApi.AcceptAllRevisions(docFileName, null, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Document track changes have been accepted successfully "); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleMailMergeTemplate.docx"; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get merge field names from document FieldNamesResponse apiResponse = wordsApi.GetDocumentFieldNames(fileName, false, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { foreach (String fieldName in apiResponse.FieldNames.Names) { Console.WriteLine(fieldName); } Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "test_uploadfile.docx"; String format = "pdf"; String storage = ""; String folder = ""; String outPath = ""; try { // Upload file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to convert document to images ResponseMessage apiResponse = wordsApi.GetDocumentWithFormat(fileName, format, storage, folder, outPath); if (apiResponse != null && apiResponse.Status.Equals("OK")) { System.Diagnostics.Debug.WriteLine("response:" + apiResponse.ResponseStream); System.IO.File.WriteAllBytes(Common.GetDataDir() + "WordFormatConverterExampleTest.pdf", apiResponse.ResponseStream); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleMailMergeTemplate.docx"; String fileDataName = "SampleMailMergeTemplateData.txt"; String cleanup = null; Boolean withRegions = false; byte[] file = System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName); byte[] data = System.IO.File.ReadAllBytes(Common.GetDataDir() + fileDataName); try { // Invoke Aspose.Words Cloud SDK API to execute mail merge without regions and without using the cloud storage ResponseMessage apiResponse = wordsApi.PutExecuteMailMergeOnline(withRegions, cleanup, file, data); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("mail merge online template has been executed successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string format = "pdf"; string outPath = null; string replaceResourcesHostTo = "new_pdf.pdf"; byte[] file = System.IO.File.ReadAllBytes(Common.GetDataDir() + "test_uploadfile.docx"); try { // Invoke Aspose.Words Cloud SDK API ResponseMessage apiResponse = wordsApi.PutConvertDocument(format, outPath, replaceResourcesHostTo, file); if (apiResponse != null && apiResponse.Status.Equals("OK")) { System.Diagnostics.Debug.WriteLine("response:" + apiResponse.ResponseStream); System.IO.File.WriteAllBytes("\\temp\\" + replaceResourcesHostTo, apiResponse.ResponseStream); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleProtectedBlankWordDocument.docx"; String destFileName = fileName; String storage = null; String folder = null; ProtectionRequest body = new ProtectionRequest(); body.Password = "******"; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to remove the protection ProtectionDataResponse apiResponse = wordsApi.DeleteUnprotectDocument(fileName, destFileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Document has been unprotected successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string name = "test_multi_pages.docx"; int commentIndex = 1; string storage = null; string folder = null; try { // Upload source file to aspose cloud storage storageApi.PutCreate(name, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + name)); // Invoke Aspose.Words Cloud SDK API to get comments Com.Aspose.Words.Model.CommentResponse apiResponse; apiResponse = wordsApi.GetComment(name, commentIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine( apiResponse.Comment.Text); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "SampleWordDocument.docx"; int hyperlinkIndex = 0; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get particular hyperlink HyperlinkResponse apiResponse = wordsApi.GetDocumentHyperlinkByIndex(fileName, hyperlinkIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Com.Aspose.Words.Model.Hyperlink hyperlink = apiResponse.Hyperlink; Console.WriteLine("Display Text: " + hyperlink.DisplayText + " Value: " + hyperlink.Value + " link: " + hyperlink.link.Href); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "GetField.docx"; int sectionIndex = 0; int paragraphIndex = 0; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to read all Runs from a Paragraph in a Word Document ResponseMessage apiResponse = wordsApi.GetParagraphRuns(fileName, sectionIndex, paragraphIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("Ok")) { Console.WriteLine("Read all Runs from a Paragraph in a Word Document, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "SampleBlankWordDocument.docx"; int sectionIndex = 0; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to extract page setup informations SectionPageSetupResponse apiResponse = wordsApi.GetSectionPageSetup(fileName, sectionIndex, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { PageSetup secPageSetup = apiResponse.PageSetup; Console.WriteLine("getPaperSize :" + secPageSetup.PaperSize + " Orientation: " + secPageSetup.Orientation); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get bookmarks from document BookmarksResponse apiResponse = wordsApi.GetDocumentBookmarks(fileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { foreach (Com.Aspose.Words.Model.Bookmark bookmark in apiResponse.Bookmarks.BookmarkList) { Console.WriteLine("Name: " + bookmark.Name + " Text: " + bookmark.Text + " link: " + bookmark.link.Href); } Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "SampleWordDocument.docx"; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get bookmarks from document by name BookmarkResponse apiResponse = wordsApi.PostUpdateDocumentBookmark(fileName, "test", "", storage, folder, null); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Bookmark updated."); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set input file name String fileName = "SampleWordDocument.docx"; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to get all drawing object from document DrawingObjectsResponse apiResponse = wordsApi.GetDocumentDrawingObjects(fileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Got the Drawing Objects successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "SampleWordDocument.docx"; int pageNumber = 1; String format = "bmp"; string storage = null; string folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to render page to specified format ResponseMessage apiResponse = wordsApi.GetRenderPage(fileName, pageNumber, format, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("Ok")) { Console.WriteLine("Render page to specified format, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace() { var localName = "test_multi_pages.docx"; var remoteName = "IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); var request = new DeleteFieldsRequest(remoteName, this.dataFolder); var api = new WordsApi(new Configuration { ApiBaseUrl = BaseProductUri, AppKey = AppKey, AppSid = AppSID, DebugMode = true }); var mockFactory = new MockFactory(); var traceListenerMock = mockFactory.CreateMock <TraceListener>(); Trace.Listeners.Add(traceListenerMock.MockObject); this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName)); traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("DELETE: http://api-dev.aspose.cloud/v1.1/words/IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace.docx/fields")); traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("Response 200: OK")); traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("{\"Code\":200,\"Status\":\"OK\"}")); traceListenerMock.Expects.AtLeastOne.Method(p => p.WriteLine(string.Empty)).With(Is.Anything); // Act api.DeleteFields(request); // Assert mockFactory.VerifyAllExpectationsHaveBeenMet(); }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "test_multi_pages.docx"; String destFileName = "updated-" + fileName; String headersFootersTypes = null; String storage = null; String folder = null; try { // Upload the file storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to remove header and footer SaaSposeResponse apiResponse = wordsApi.DeleteHeadersFooters(fileName, headersFootersTypes, destFileName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("All headers and footers have been deleted successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public void ExampleAcceptAllRevisionsOnline() { var wordsApi = new WordsApi(config); var fileName = "test_doc.docx"; // Calls AcceptAllRevisionsOnline method for document in cloud. using var documentStream = File.OpenRead(fileName); var request = new AcceptAllRevisionsOnlineRequest(documentStream); var acceptAllRevisionsOnlineResult = wordsApi.AcceptAllRevisionsOnline(request); using (var fileStream = File.Create("test_result.docx")) { acceptAllRevisionsOnlineResult.Document.CopyTo(fileStream); } }
public void TestWrongClientIdThrowsException() { Assert.Throws <ArgumentException>(() => new WordsApi(string.Empty, string.Empty)); var api = new WordsApi(new Configuration { ClientSecret = "qqqq", ClientId = "tttt", ApiBaseUrl = "https://api-qa.aspose.cloud", AuthType = AuthType.OAuth2, DebugMode = true }); Assert.Throws <ApiException>(() => api.GetAvailableFonts(new GetAvailableFontsRequest())); }
static public List <string> GetWords(string text) { Configuration.Default.AddApiKey("Apikey", APIKey); var apiInstance = new WordsApi(); try { string result = apiInstance.WordsGetWordsString(text); List <string> Words_ = result.Replace("\"", "").Split(',').ToList <string>(); return(Words_); } catch (Exception) { return(null); } }
public void ExampleAcceptAllRevisions() { var wordsApi = new WordsApi(config); var fileName = "test_doc.docx"; // Upload original document to cloud storage. using var fileContentStream = File.OpenRead(fileName); var uploadFileRequest = new UploadFileRequest(fileContentStream, fileName); wordsApi.UploadFile(uploadFileRequest); // Calls AcceptAllRevisions method for document in cloud. var request = new AcceptAllRevisionsRequest(fileName); wordsApi.AcceptAllRevisions(request); }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string fileName = "test_multi_pages.docx"; int sectionIndex = 0; int paragraphIndex = 0; string insertBeforeNode = null; string destFileName = "test.docx"; string storage = null; string folder = null; FormField body = new FormField(); Link lnk = new Link(); lnk.Href = ""; body.Name = "FullName"; body.Enabled = true; body.CalculateOnExit = true; body.StatusText = ""; body.link = lnk; body.TextInputType = "Regular"; body.TextInputDefault = ""; body.TextInputFormat = "UPPERCASE"; try { // Upload the file storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Words Cloud SDK API to add form fileds FormFieldResponse apiResponse = wordsApi.PutFormField(fileName, sectionIndex, paragraphIndex, insertBeforeNode, destFileName, storage, folder, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Form field has been added successfully"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static void Run() { // ExStart:1 WordsApi wordsApi = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); // Set destination file name String destFileName = "test_doc.docx"; // Set source file name String sourceFileName = "test_uploadfile.docx"; Com.Aspose.Words.Model.DocumentEntryList body = new Com.Aspose.Words.Model.DocumentEntryList(); List <Com.Aspose.Words.Model.DocumentEntry> docEntries = new List <Com.Aspose.Words.Model.DocumentEntry>(); Com.Aspose.Words.Model.DocumentEntry docEntry = new Com.Aspose.Words.Model.DocumentEntry(); docEntry.Href = sourceFileName; docEntry.ImportFormatMode = "KeepSourceFormatting"; docEntries.Add(docEntry); body.DocumentEntries = docEntries; try { // Upload source file to aspose cloud storage storageApi.PutCreate(sourceFileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + destFileName)); // Upload destination file to aspose cloud storage storageApi.PutCreate(destFileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + sourceFileName)); // Invoke Aspose.Words Cloud SDK API to append word document Com.Aspose.Words.Model.DocumentResponse apiResponse = wordsApi.PostAppendDocument(destFileName, null, null, null, body); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Documents have been appended successfully"); Com.Aspose.Storage.Model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null); System.Diagnostics.Debug.WriteLine("response:" + storageRes.ResponseStream); System.IO.File.WriteAllBytes(Common.GetDataDir() + sourceFileName, storageRes.ResponseStream); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }