Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-words/14198fdb22ad67a3a4106cc5ad86d565 to your computer and use it in GitHub Desktop.
Save aspose-words/14198fdb22ad67a3a4106cc5ad86d565 to your computer and use it in GitHub Desktop.
Aspose_Words_Android_Cloud
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get all the bookmarks from a
// word document
BookmarksResponse apiResponse = wordsApi.GetDocumentBookmarks(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
// display the bookmarks info
for (Bookmark bookmark : apiResponse.getBookmarks().getBookmarkList()) {
System.out.println("Name: " + bookmark.getName() + " Text: " + bookmark.getText() + " link: "
+ bookmark.getLink().getHref());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String bookmarkName = "_Toc76372689";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get the bookmark by given
// name from a word document
BookmarkResponse apiResponse = wordsApi.GetDocumentBookmarkByName(fileName, bookmarkName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
if (apiResponse.getBookmark() != null) {
// display bookmark info
System.out.println("Name: " + apiResponse.getBookmark().getName() + " Text: "
+ apiResponse.getBookmark().getText() + " link: "
+ apiResponse.getBookmark().getLink().getHref());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String bookmarkName = "aspose";
String destFileName = null;
BookmarkData body = new BookmarkData();
body.setName("aspose");
body.setText("This is updated Bookmark");
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// invoke Aspose.Words Cloud SDK API to update the bookmark from a
// word document
BookmarkResponse apiResponse = wordsApi.PostUpdateDocumentBookmark(fileName, bookmarkName, destFileName,
storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
if (apiResponse.getBookmark() != null) {
// display bookmark info
System.out.println("Name: " + apiResponse.getBookmark().getName() + " Text: "
+ apiResponse.getBookmark().getText() + " link: "
+ apiResponse.getBookmark().getLink().getHref());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set destination file name
String destFileName = "AppendFile_destination.docx";
// set source file name
String sourceFileName = "AppendFile_source.docx";
DocumentEntryList body = new DocumentEntryList();
ArrayList<DocumentEntry> docEntries = new ArrayList<DocumentEntry>();
DocumentEntry docEntry = new DocumentEntry();
docEntry.setHref(sourceFileName);
docEntry.setImportFormatMode("KeepSourceFormatting");
docEntries.add(docEntry);
body.setDocumentEntries(docEntries);
File sourceFile = Utils.stream2file("AppendFile_destination","docx", context.getResources().openRawResource(R.raw.docsample));
File destinationFile = Utils.stream2file("AppendFile_source","docx", context.getResources().openRawResource(R.raw.docsample));
// upload source file to aspose cloud storage
storageApi.PutCreate(sourceFileName, "", "",
sourceFile);
// upload destination file to aspose cloud storage
storageApi.PutCreate(destFileName, "", "",destinationFile);
// invoke Aspose.Words Cloud SDK API to append word document
DocumentResponse apiResponse = wordsApi.PostAppendDocument(destFileName, null, null, null, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Documents have been appended successfully");
// download appended document from storage server
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
Utils.copyInputStreamToFile(storageRes.getInputStream(),sourceFile);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "test_doc.docx";
// set the desire output format
String format = "pdf";
String storage = "";
String folder = "";
String outPath = "";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to convert words document to
// required format
ResponseMessage apiResponse = wordsApi.GetDocumentWithFormat(fileName, format, storage, folder, outPath);
if (apiResponse != null && apiResponse.getInputStream() != null) {
// save com.aspose.words.model.api response to file
InputStream responseStream = apiResponse.getInputStream();
Utils.copyInputStreamToFile(responseStream,input);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String format = "pdf";
Integer from = 2;
Integer to = 3;
Boolean zipOutput = false;
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
input);
// invoke Aspose.Words Cloud SDK API to split word document
SplitDocumentResponse apiResponse = wordsApi.PostSplitDocument(fileName, format, from, to, zipOutput,
storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Document has been splitted to pfds successfully");
// download splitted pdfs from storage server
for (Link pageLink : apiResponse.getSplitResult().getPages()) {
String outputFileName = pageLink.getHref();
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(outputFileName, null,
null);
InputStream responseStream = storageRes.getInputStream();
File outputFile=Utils.createTempFile(outputFileName,"docx");
Utils.copyInputStreamToFile(storageRes.getInputStream(),outputFile);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get list of all drawing
// objects present in a word document
DrawingObjectsResponse apiResponse = wordsApi.GetDocumentDrawingObjects(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
List<LinkElement> linkElements = apiResponse.getDrawingObjects().getList();
// export all drawing objects to PNG
for (int objectIndex = 0; objectIndex < linkElements.size(); objectIndex++) {
ResponseMessage pngImageDataRes = wordsApi.GetDocumentDrawingObjectByIndexWithFormat(fileName,
objectIndex, "png", storage, folder);
if (pngImageDataRes != null && pngImageDataRes.getStatus().equals("OK")
&& pngImageDataRes.getInputStream() != null) {
String destFileName = "DrawingObject_" + objectIndex ;
// save the image data
File desination=Utils.createTempFile(destFileName, ".png");
Utils.copyInputStreamToFile(pngImageDataRes.getInputStream(),desination);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
Integer objectIndex = 0;
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get drawing object by index
// present in a word document
DrawingObjectResponse apiResponse = wordsApi.GetDocumentDrawingObjectByIndex(fileName, objectIndex, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
DrawingObject drawingObject = apiResponse.getDrawingObject();
// display basic drawingObject info
System.out.println("Height: " + drawingObject.getHeight());
System.out.println("Width: " + drawingObject.getWidth());
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// set input file name
String fileName = "SampleOlePdfData.docx";
Integer objectIndex = 0;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// invoke Aspose.Words Cloud SDK API to get ole
// drawing object by index in a word document
ResponseMessage apiResponse = wordsApi.GetDocumentDrawingObjectOleData(fileName, objectIndex, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK") && apiResponse.getInputStream() != null) {
String destFileName = "OLEDrawingObject_" + objectIndex;
File desination=Utils.createTempFile(destFileName, ".png");
Utils.copyInputStreamToFile(apiResponse.getInputStream(),desination);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
PageNumber body = new PageNumber();
body.setFormat("{PAGE} of {NUMPAGES}");
body.setAlignment("center");
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to insert page number field
// into a word document
DocumentResponse apiResponse = wordsApi.PostInsertPageNumbers(fileName, fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Page Number Field has been inserted successfully");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(fileName, null, null);
InputStream responseStream = storageRes.getInputStream();
File desination=Utils.createTempFile("temp1234", ".docx");
Utils.copyInputStreamToFile(storageRes.getInputStream(),desination);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleMailMergeTemplate.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
new File(GetMergeFieldsFromDocumentExample.class.getResource("/" + fileName).toURI()));
// invoke Aspose.Words Cloud SDK API to get merge field names from a
// word document
FieldNamesResponse apiResponse = wordsApi.GetDocumentFieldNames(fileName, false, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
// Get all merge field names from document
for (String fieldName : apiResponse.getFieldNames().getNames()) {
System.out.println(fieldName);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleBlankWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
Integer sectionIndex = 0;
Integer paragraphIndex = 0;
String insertBeforeNode = "";
String destFileName = "Updated-" + fileName;
String storage = "";
String folder = "";
String xml = "<FormFieldTextInput>" + "<Name>MyName</Name>" + "<Enabled>true</Enabled>" + "<StatusText />"
+ "<OwnStatus>false</OwnStatus>" + "<HelpText />" + "<OwnHelp>false</OwnHelp>"
+ "<CalculateOnExit>true</CalculateOnExit>" + "<EntryMacro />" + "<ExitMacro />"
+ "<TextInputFormat>UPPERCASE</TextInputFormat>" + "<TextInputType>Regular</TextInputType>"
+ "<TextInputDefault>Farooq Sheikh</TextInputDefault>" + "</FormFieldTextInput>";
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to add field in the document
FormFieldResponse apiResponse = wordsApi.PutFormField(fileName, sectionIndex, paragraphIndex,
insertBeforeNode, destFileName, storage, folder, xml.getBytes("UTF-8"));
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Form field has been added successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", storage, input);
// invoke Aspose.Words Cloud SDK API to update fields in the whole
// document
DocumentResponse apiResponse = wordsApi.PostUpdateDocumentFields(fileName, fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Document fields have been updated successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleHeaderFooterWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
String destFileName = "updated-" + fileName;
String headersFootersTypes = null;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to remove all headers and
// footers from a word document
/*
SaaSposeResponse apiResponse = wordsApi.DeleteHeadersFooters(fileName, headersFootersTypes, destFileName,
storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("All headers and footers have been deleted successfully");
}
*/
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleHeaderFooterWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
String destFileName = "updated-" + fileName;
String headersFootersTypes = null;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to remove all headers and
// footers from a word document
/*
SaaSposeResponse apiResponse = wordsApi.DeleteHeadersFooters(fileName, headersFootersTypes, destFileName,
storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("All headers and footers have been deleted successfully");
}*/
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleExecuteTemplate.docx";
File input = Utils.stream2file("SampleExecuteTemplate","docx", context.getResources().openRawResource(R.raw.sampleexecutetemplate));
String cleanup = null;
String destFileName = "updated-" + fileName;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = null;
Boolean withRegions = null;
File file;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
input);
// set input file data name
String fileDataName = "SampleExecuteTemplateData.txt";
File fileData = Utils.stream2file("SampleExecuteTemplateData","txt", context.getResources().openRawResource(R.raw.sampleexecutetemplate));
// invoke Aspose.Words Cloud SDK API to execute mail merge template
// and populate a word document from XML data
DocumentResponse apiResponse = wordsApi.PostExecuteTemplate(fileName, cleanup, destFileName, storage,
folder, useWholeParagraphAsRegion, withRegions, fileData);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleExecuteTemplate.docx";
File input = Utils.stream2file("SampleExecuteTemplate","docx", context.getResources().openRawResource(R.raw.sampleexecutetemplate));
String cleanup = null;
String destFileName = "updated-" + fileName;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = null;
Boolean withRegions = null;
File file;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// set input file data name
File fileDataName = Utils.stream2file("SampleExecuteTemplateData","txt", context.getResources().openRawResource(R.raw.sampleexecutetemplatedata));
// invoke Aspose.Words Cloud SDK API to execute mail merge template
// and populate a word document from XML data
DocumentResponse apiResponse = wordsApi.PostExecuteTemplate(fileName, cleanup, destFileName, storage,
folder, useWholeParagraphAsRegion, withRegions, input);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleInvoiceTemplate.doc";
File input = Utils.stream2file("SampleInvoiceTemplate","doc", context.getResources().openRawResource(R.raw.sampleinvoicetemplate));
String cleanup = null;
String destFileName = "updated-" + fileName;
String mailMergeDataFile = null;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = false;
Boolean withRegions = true;
File file;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// set input file data name
String fileDataName = "SampleInvoiceTemplateData.txt";
File fileData = Utils.stream2file("SampleInvoiceTemplateData","txt", context.getResources().openRawResource(R.raw.sampleexecutetemplatedata));
// invoke Aspose.Words Cloud SDK API to execute mail merge and
// populate a word document from XML data
DocumentResponse apiResponse = wordsApi.PostDocumentExecuteMailMerge(fileName, withRegions,
mailMergeDataFile, cleanup, destFileName, storage, folder, useWholeParagraphAsRegion, input);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "MathsObject.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("MathsObject","docx", context.getResources().openRawResource(R.raw.mathsobject));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// invoke Aspose.Words Cloud SDK API
SaaSposeResponse apiResponse = wordsApi.DeleteOfficeMathObjects("MathsObject.docx", 1, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Office Math Object Delted from Document");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "MathsObject.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("MathsObject","docx", context.getResources().openRawResource(R.raw.mathsobject));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
OfficeMathObjectsResponse apiResponse = wordsApi.GetOfficeMathObjects("MathsObject.docx", storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Reading Math Objects Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "MathsObject.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("MathsObject","docx", context.getResources().openRawResource(R.raw.mathsobject));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
OfficeMathObjectsResponse apiResponse = wordsApi.GetOfficeMathObjects("MathsObject.docx",1, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Reading Math Objects from Paragraph Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "MathsObject.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("MathsObject","docx", context.getResources().openRawResource(R.raw.mathsobject));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
OfficeMathObjectsResponse apiResponse = wordsApi.GetOfficeMathObjects("MathsObject.docx",0,1, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Reading Math Objects from Section Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "MathsObject.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("MathsObject","docx", context.getResources().openRawResource(R.raw.mathsobject));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
OfficeMathObjectsResponse apiResponse = wordsApi.GetOfficeMathObjects("MathsObject.docx",0,0,0, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Reading Math Objects by Index Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get list of paragraphs from
// a word document
ParagraphLinkCollectionResponse apiResponse = wordsApi.GetDocumentParagraphs(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
ParagraphLink docProperty = apiResponse.getParagraphs().getParagraphLinkList().get(0);
// display document paragraphs info
for (ParagraphLink docParagraphLink : apiResponse.getParagraphs().getParagraphLinkList()) {
System.out.println("Link : " + docParagraphLink.getLink());
System.out.println("Text : " + docParagraphLink.getText());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
Integer index = 0;
Integer runIndex = 0;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// invoke Aspose.Words Cloud SDK API to get a font related
// information of a specific run of a paragraph from a word document
FontResponse apiResponse = wordsApi.GetDocumentParagraphRunFont(fileName, index, runIndex, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
Font runFont = apiResponse.getFont();
// display run font info
if (runFont != null) {
System.out.println("Font Name : " + runFont.getName());
System.out.println("Style : " + runFont.getStyleName());
System.out.println("Size : " + runFont.getSize());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
Integer index = 1;
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get a specific paragraph
// from a word document
ParagraphResponse apiResponse = wordsApi.GetDocumentParagraph(fileName, index, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
Paragraph docParagraph = apiResponse.getParagraph();
// display document paragraph info
if (docParagraph != null) {
System.out.println("NoteId : " + docParagraph.getNodeId());
System.out.println("Link : " + docParagraph.getLink().getHref());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
Integer index = 1;
Integer runIndex = 0;
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
input);
// invoke Aspose.Words Cloud SDK API to get a specific run of a
// paragraph from a word document
RunResponse apiResponse = wordsApi.GetDocumentParagraphRun(fileName, index, runIndex, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
Run docParagraphRun = apiResponse.getRun();
// display document paragraph run info
if (docParagraphRun != null) {
System.out.println("NoteId : " + docParagraphRun.getNodeId());
System.out.println("Link : " + docParagraphRun.getText());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String destFileName = "updated-" + fileName;
Integer index = 0;
Integer runIndex = 0;
String storage = null;
String folder = null;
Font body = new Font();
body.setBold(true);
body.setSize(31.0);
body.setName("Calibri");
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
input);
// invoke Aspose.Words Cloud SDK API to update font of a specific
// run of a paragraph present in a word document
FontResponse apiResponse = wordsApi.PostDocumentParagraphRunFont(fileName, index, runIndex, storage, folder,
destFileName, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("paragraph run font has been updated successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String propertyName = "AsposeAuthor";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to delete document property by
// given name from a word document
SaaSposeResponse apiResponse = wordsApi.DeleteDocumentProperty(fileName, propertyName, fileName, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("The document property has been removed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String propertyName = "Author";
String storage = null;
String folder = null;
DocumentProperty body = new DocumentProperty();
body.setName("Author");
body.setValue("Farooq Sheikh");
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to update document property by
// given name from a word document
DocumentPropertyResponse apiResponse = wordsApi.PutUpdateDocumentProperty(fileName, propertyName, fileName,
storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
DocumentProperty docProperty = apiResponse.getDocumentProperty();
if (docProperty != null) {
// display updated document property info
System.out.println(docProperty.getName() + " : " + docProperty.getValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get all document properties
// from a word document
DocumentPropertiesResponse apiResponse = wordsApi.GetDocumentProperties(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
// display document property info
for (DocumentProperty docProperty : apiResponse.getDocumentProperties().getList()) {
System.out.println(docProperty.getName() + " : " + docProperty.getValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String propertyName = "Author";
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
new File(ReadingASinglePropertyFromDocumentExample.class.getResource("/" + fileName).toURI()));
// invoke Aspose.Words Cloud SDK API to get document property by
// given name from a word document
DocumentPropertyResponse apiResponse = wordsApi.GetDocumentProperty(fileName, propertyName, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
DocumentProperty docProperty = apiResponse.getDocumentProperty();
if (docProperty != null) {
// display document property info
System.out.println(docProperty.getName() + " : " + docProperty.getValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// set input file name
String fileName = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to modify protection of a word
// document
ProtectionDataResponse apiResponse = wordsApi.GetDocumentProtection(fileName, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println(
"Get Document protection completed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// set input file name
String fileName = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
ProtectionRequest body = new ProtectionRequest();
body.setPassword("aspose");
body.setNewPassword("");
body.setProtectionType("NoProtection");
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to modify protection of a word
// document
ProtectionDataResponse apiResponse = wordsApi.PostChangeDocumentProtection(fileName, destFileName, storage,
folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println(
"Document protection property has been changed from protected to unprotected successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// set input file name
String fileName = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
ProtectionRequest body = new ProtectionRequest();
body.setPassword("aspose");
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to unprotect a word document
ProtectionDataResponse apiResponse = wordsApi.DeleteUnprotectDocument(fileName, destFileName, storage,
folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Document has been unprotected successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.sampleexecutetemplate));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
// invoke Aspose.Words Cloud SDK API
SearchResult apiResponse = wordsApi.Search(fileName,"abc", storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Search Result Example Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
String fileName = "SampleBlankWordDocument.docx";
int sectionIndex = 0;
String storage = null;
String folder = null;
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// Upload the file
storageApi.PutCreate(fileName, "", storage, new File(ModifyingDocumentPropertyExample.class.getResource("/" + fileName).toURI()));
// Invoke Aspose.Words Cloud SDK API to extract page setup
// informations
SectionPageSetupResponse apiResponse = wordsApi.GetSectionPageSetup(fileName, sectionIndex, storage,
folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
PageSetup secPageSetup = apiResponse.getPageSetup();
System.out.println(
"getPaperSize :" + secPageSetup.getPaperSize() + " Orientation: " + secPageSetup.getOrientation());
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get list of all sections
// present from a word document
SectionLinkCollectionResponse apiResponse = wordsApi.GetSections(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
// get sections href
for (SectionLink sectionLink : apiResponse.getSections().getSectionLinkList()) {
System.out.println(sectionLink.getLink().getHref());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
Integer sectionIndex = 0;
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
input);
// invoke Aspose.Words Cloud SDK API to get a specific section
// present from a word document
SectionResponse apiResponse = wordsApi.GetSection(fileName, sectionIndex, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
// get section href
System.out.println(apiResponse.getSection().getLink().getHref());
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
String fileName = "SampleBlankWordDocument.docx";
String destFileName = "updated-" + fileName;
int sectionIndex = 0;
String storage = null;
String folder = null;
PageSetup body = new PageSetup();
body.setRtlGutter(true);
body.setOrientation("Portrait");
body.setPaperSize("A5");
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// Upload the file
storageApi.PutCreate(fileName, "", storage, input);
// Invoke Aspose.Words Cloud SDK API to update page setup
SectionPageSetupResponse apiResponse = wordsApi.UpdateSectionPageSetup(fileName, sectionIndex, storage,
folder, destFileName, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
PageSetup secPageSetup = apiResponse.getPageSetup();
System.out.println(
"getPaperSize :" + secPageSetup.getPaperSize() + " Orientation: " + secPageSetup.getOrientation());
}
} catch (Exception ex) {
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "TableDocument.doc";
String storage = null;
String folder = null;
File input = Utils.stream2file("TableDocument","docx", context.getResources().openRawResource(R.raw.tabledocument));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
SaaSposeResponse apiResponse = wordsApi.DeleteTable("TableDocument.doc", "tables/1", storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Table deleted from Word Document");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "TableDocument.doc";
String storage = null;
String folder = null;
File input = Utils.stream2file("TableDocument","docx", context.getResources().openRawResource(R.raw.tabledocument));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",input);
//Invoke the API
TableLinkCollectionResponse apiResponse = wordsApi.GetTables("TableDocument.doc", "tables/1/rows/0/borders", storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Reading Table Information Done");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
ReplaceTextRequest body = new ReplaceTextRequest();
body.setOldValue ("aspose");
body.setNewValue ( "aspose.com");
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to get all the bookmarks from a
// word document
ReplaceTextResponse apiResponse = wordsApi.PostReplaceText(fileName, fileName, storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Text replaced successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String destFileName = "updated-" + fileName;
Double rotationAngle = 0.0;
String storage = "";
String folder = null;
String text = "New";
WatermarkText body = new WatermarkText();
body.setText("aspose.com");
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to 3rd party cloud storage
storageApi.PutCreate(fileName, "", storage,
input);
// invoke Aspose.Words Cloud SDK API to add watermark text in a word
// document
DocumentResponse apiResponse = wordsApi.PostInsertWatermarkText(fileName, text, rotationAngle, destFileName,
storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Watermark text has been added successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleBlankWordDocument.docx";
String destFileName = "updated-" + fileName;
Double rotationAngle = 0.0;
String storage = "AsposeDropboxStorage";
String folder = null;
//String image = "background.png";
File file;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
File image = Utils.stream2file("background",".png", context.getResources().openRawResource(R.raw.asposelogo));
// upload input file to 3rd party cloud storage
storageApi.PutCreate(fileName, "", storage, input);
// upload input file to 3rd party cloud storage
storageApi.PutCreate("background.png", "", storage, image);
// invoke Aspose.Words Cloud SDK API to add watermark image in a
// word document
DocumentResponse apiResponse = wordsApi.PostInsertWatermarkImage(fileName, destFileName, rotationAngle,
"background.png", storage, folder, image);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Watermark image has been added successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Cloud
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, true);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, true);
// set input file name
String fileName = "SampleWordDocument.docx";
String destFileName = "updated-" + fileName;
String storage = null;
String folder = null;
File input = Utils.stream2file("SampleWordDocument","docx", context.getResources().openRawResource(R.raw.docsample));
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", input);
// invoke Aspose.Words Cloud SDK API to remove watermark image from
// a word document
DocumentResponse apiResponse = wordsApi.DeleteDocumentWatermark(fileName, destFileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Watermark image has been removed successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment