Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/452cf6c7f33f8e738f0c9d2bc5d0d81f to your computer and use it in GitHub Desktop.
Save aspose-cloud/452cf6c7f33f8e738f0c9d2bc5d0d81f to your computer and use it in GitHub Desktop.
Examples-Java-aspose-cloud-words-examples-src-main-java
Examples-Java-aspose-cloud-words-examples-src-main-java
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(GettingAllBookmarksExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(ReadingBookmarkExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
path.toFile());
// 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-cloud/aspose-words-cloud-java
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");
Path path=Utils.getPath(UpdatingBookmarkTextExample.class, fileName);
String storage = null;
String folder = null;
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
// 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-cloud/aspose-words-cloud-java
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);
Path p1=Utils.getPath(AppendDocumentExample.class, sourceFileName);
Path p2=Utils.getPath(AppendDocumentExample.class, destFileName);
// upload source file to aspose cloud storage
storageApi.PutCreate(sourceFileName, "", "",p1.toFile());
// upload destination file to aspose cloud storage
storageApi.PutCreate(destFileName, "", "",p2.toFile());
// 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();
final Path destination = Paths.get(sourceFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, false);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, false);
// set input file name
String fileName = "SampleWordDocument.docx";
// set the desire output format
String format = "pdf";
String storage = "";
String folder = "";
String outPath = "";
Path p1=Utils.getPath(ConvertDocumentToFormatExample.class, fileName);
// upload file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// invoke Aspose.Words Cloud SDK API to convert words document to
// required format
ResponseMessage apiResponse = wordsApi.GetDocumentWithFormat(fileName, format, storage, folder, outPath,"fonts");
if (apiResponse != null && apiResponse.getInputStream() != null) {
// save api response to file
InputStream responseStream = apiResponse.getInputStream();
final Path destination = Paths.get("SampleWordDocument.pdf");
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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);
SaveOptions saveOptionsData = new SaveOptions();
saveOptionsData.setFileName("");
saveOptionsData.setSaveFormat("doc");
LoadWebDocumentData loadOtion = new LoadWebDocumentData();
loadOtion.setLoadingDocumentUrl("http://www.aspose.com/corporate/default.aspx");
loadOtion.setSaveOptions(saveOptionsData);
// invoke Aspose.Words Cloud SDK API
SaveResponse apiResponse = wordsApi.PostLoadWebDocument(loadOtion);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("OK");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
try {
// Instantiate Aspose Storage API SDK
StorageApi storageApi = new StorageApi(Configuration.apiKey, Configuration.appSID, false);
// Instantiate Aspose Words API SDK
WordsApi wordsApi = new WordsApi(Configuration.apiKey, Configuration.appSID, false);
// set input file name
String fileName = "SampleWordDocument.docx";
// set the desire output format
String format = "bmp";
String storage = "";
String folder = "";
Integer pageNumber = 1;
Path p1 = Utils.getPath(ConvertDocumentToFormatExample.class, fileName);
// upload file to aspose cloud storage
storageApi.PutCreate(fileName, "", "", p1.toFile());
// invoke Aspose.Words Cloud SDK API to convert words document to
// required format
ResponseMessage apiResponse = wordsApi.GetRenderPage(fileName, pageNumber, format, storage, folder);
if (apiResponse != null) {
// save api response to file
System.out.println("Page rendered successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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 fileName = "MathsObject.docx";
Path p1=Utils.getPath(SaveDocumentAsExample.class, fileName);
SaveOptions saveOptions = new SaveOptions();
saveOptions.setSaveFormat("bmp");
saveOptions.setFileName("Data.bmp");
saveOptions.setHorizontalResolution(700);
saveOptions.setVerticleResolution(400);
// upload source file to Aspose cloud storage
storageApi.PutCreate(fileName, "", "", p1.toFile());
// invoke Aspose.Words Cloud SDK API
SaveResponse apiResponse = wordsApi.PostDocumentSaveAs(fileName, null, null, saveOptions);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("OK");
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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();
final Path destination = Paths.get("./" + outputFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
}
} 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 =null ;
Integer to = null;
Boolean zipOutput = false;
String storage = null;
String folder = null;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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();
final Path destination = Paths.get("./" + outputFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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 + ".png";
// save the image data
final Path destination = Paths.get(destFileName);
Files.copy(pngImageDataRes.getInputStream(), destination, StandardCopyOption.REPLACE_EXISTING);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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 = "SampleOlePdfData.docx";
Integer objectIndex = 0;
String storage = null;
String folder = null;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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 + ".pdf";
// save the ole data
final Path destination = Paths.get("./" + destFileName);
Files.copy(apiResponse.getInputStream(), destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
PageNumber body = new PageNumber();
body.setFormat("{PAGE} of {NUMPAGES}");
body.setAlignment("center");
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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();
final Path destination = Paths.get("./" + fileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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";
String storage = null;
String folder = null;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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-cloud/aspose-words-cloud-java
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";
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>";
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get("./" + destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", storage,
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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";
String destFileName = "updated-" + fileName;
String headersFootersTypes = null;
String storage = null;
String folder = null;
String revisionDateTime = "2017-02-20";
String revisionAuthor = "Mateen";
// upload input file to aspose cloud storage
Path p1 = Utils.getPath(AppendDocumentExample.class, fileName);
storageApi.PutCreate(fileName, "", "", p1.toFile());
// 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,revisionAuthor,revisionDateTime);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("All headers and footers have been deleted successfully");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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";
String cleanup = null;
String destFileName = "updated-" + fileName;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = null;
Boolean withRegions = null;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// set input file data name
String fileDataName = "SampleExecuteTemplateData.txt";
Path p2=Utils.getPath(AppendDocumentExample.class, fileDataName);
// 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, p2.toFile());
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get("./" + destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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";
String cleanup = null;
String destFileName = "updated-" + fileName;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = null;
Boolean withRegions = null;
Path p1=Utils.getPath(AppendDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// set input file data name
String fileDataName = "SampleExecuteTemplateData.txt";
Path p2=Utils.getPath(AppendDocumentExample.class, fileDataName);
// 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, p2.toFile());
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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";
String cleanup = null;
String destFileName = "updated-" + fileName;
String mailMergeDataFile = null;
String storage = null;
String folder = null;
Boolean useWholeParagraphAsRegion = false;
Boolean withRegions = true;
Path p1=Utils.getPath(ExecuteMailMergeWithRegionsExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// set input file data name
String fileDataName = "SampleInvoiceTemplateData.txt";
Path p2=Utils.getPath(ExecuteMailMergeWithRegionsExample.class, fileDataName);
// 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, p2.toFile());
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("mail merge template has been executed successfully");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get("./" + destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(DeleteMathObjectByIndexExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(ReadAllMathObjectsExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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;
Path path=Utils.getPath(ReadAllMathObjectsFromParagraphExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(ReadAllMathObjectsFromSectionExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(ReadOfficeMathObjectsByIndexExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(ReadingAllParagraphsFromDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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-cloud/aspose-words-cloud-java
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 = 0;
Integer runIndex = 0;
String storage = null;
String folder = null;
Path p1=Utils.getPath(ReadingFontInformationFromDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(ReadingParticularParagraphFromDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(ReadingSpecificRunParagraphExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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-cloud/aspose-words-cloud-java
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");
Path p1=Utils.getPath(ReadingSpecificRunParagraphExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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");
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",p1.toFile());
// 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-cloud/aspose-words-cloud-java
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 = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
ProtectionRequest body = new ProtectionRequest();
body.setPassword("aspose");
body.setNewPassword("");
body.setProtectionType("NoProtection");
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get("./" + destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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 = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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 = "SampleProtectedBlankWordDocument.docx";
String destFileName = fileName;
String storage = null;
String folder = null;
ProtectionRequest body = new ProtectionRequest();
body.setPassword("aspose");
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} 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;
Path path=Utils.getPath(SearchTextWordDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
// 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
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;
Path path=Utils.getPath(SearchTextWordDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
// 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);
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// Upload the file
storageApi.PutCreate(fileName, "", storage,p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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 sectionIndex = 0;
String storage = null;
String folder = null;
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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-cloud/aspose-words-cloud-java
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);
Path p1=Utils.getPath(DeletingDocumentPropertyExample.class, fileName);
// Upload the file
storageApi.PutCreate(fileName, "", storage, p1.toFile());
// 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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(DeletingTablesFromDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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-cloud/aspose-words-cloud-java
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;
Path path=Utils.getPath(ReadingAllTablesFromDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",path.toFile());
//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
// 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);
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
ReplaceTextRequest body = new ReplaceTextRequest();
body.setOldValue ("aspose");
body.setNewValue ( "aspose.com");
body.setIsOldValueRegex(false);
Path p1=Utils.getPath(FindReplaceTextExample.class, fileName);
String revisionDateTime = "2017-02-20";
String revisionAuthor = "Mateen";
try
{
// Upload the file
storageApi.PutCreate(fileName, "", "", p1.toFile());
// Invoke Aspose.Words Cloud SDK API to replace text
ReplaceTextResponse apiResponse = wordsApi.PostReplaceText(fileName, fileName, storage, folder, body,revisionAuthor,revisionDateTime);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Text replaced successfully");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
// 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);
String fileName = "SampleWordDocument.docx";
String storage = null;
String folder = null;
Path p1=Utils.getPath(GetDocumentTextItemsExample.class, fileName);
try
{
// Upload the file
storageApi.PutCreate(fileName, "", "", p1.toFile());
// Invoke Aspose.Words Cloud SDK API to replace text
TextItemsResponse apiResponse = wordsApi.GetDocumentTextItems(fileName, storage, folder);
if (apiResponse != null && apiResponse.getStatus().equals("OK"))
{
System.out.println("Text replaced successfully");
for(TextItem t : apiResponse.getTextItems().getList()){
System.out.println(t.getText());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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 = null;
String folder = null;
String text = "New";
WatermarkText body = new WatermarkText();
body.setText("aspose.com");
body.setRotationAngle(rotationAngle);
Path p1=Utils.getPath(AddWatermarkTextDocumentExample.class, fileName);
// upload input file to 3rd party cloud storage
storageApi.PutCreate(fileName, "", storage,
p1.toFile());
// invoke Aspose.Words Cloud SDK API to add watermark text in a word
// document
/*
* The third argument is invalid. Will be fixed in next release.
*/
DocumentResponse apiResponse = wordsApi.PostInsertWatermarkText(fileName, text, null, destFileName,
storage, folder, body);
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Watermark text has been added successfully");
// download updated file from 3rd party cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null,
storage);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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 = null;
String folder = null;
String image = "background.png";
Path p1=Utils.getPath(AddWaterMarkToDocumentExample.class, fileName);
Path p2=Utils.getPath(AddWaterMarkToDocumentExample.class, fileName);
// upload input file to 3rd party cloud storage
storageApi.PutCreate(fileName, "", storage,
p1.toFile());
// upload input file to 3rd party cloud storage
storageApi.PutCreate(image, "", storage,
p2.toFile());
// invoke Aspose.Words Cloud SDK API to add watermark image in a
// word document
DocumentResponse apiResponse = wordsApi.PostInsertWatermarkImage(fileName, destFileName, rotationAngle,
image, storage, folder, p2.toFile());
if (apiResponse != null && apiResponse.getStatus().equals("OK")) {
System.out.println("Watermark image has been added successfully");
// download updated file from 3rd party cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null,
storage);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/aspose-words-cloud/aspose-words-cloud-java
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;
Path p1=Utils.getPath(AddWaterMarkToDocumentExample.class, fileName);
// upload input file to aspose cloud storage
storageApi.PutCreate(fileName, "", "",
p1.toFile());
// 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");
// download updated file from cloud storage
com.aspose.storage.model.ResponseMessage storageRes = storageApi.GetDownload(destFileName, null, null);
InputStream responseStream = storageRes.getInputStream();
final Path destination = Paths.get(destFileName);
Files.copy(responseStream, destination, StandardCopyOption.REPLACE_EXISTING);
}
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment