Last active
December 2, 2021 07:26
-
-
Save aspose-cloud/bfc33fb09aa1df14c8b3115fa7a4d9a6 to your computer and use it in GitHub Desktop.
Aspose.Words-Cloud-SDK-.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The GIST contains SDK Examples of Aspose.Words Cloud SDK for .NET. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string clientID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string clientSecret = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(clientID, clientSecret); | |
// input file name | |
String filename = "Volume 1.docx"; | |
// index of comment | |
int commentIndex = 0; | |
Aspose.Words.Cloud.Sdk.Model.NodeLink link = new Aspose.Words.Cloud.Sdk.Model.NodeLink() | |
{ | |
NodeId = "0.1.0.1.1.1.1" | |
}; | |
Aspose.Words.Cloud.Sdk.Model.DocumentPosition documentPosition = new Aspose.Words.Cloud.Sdk.Model.DocumentPosition() | |
{ | |
Node = link, | |
Offset = 0 | |
}; | |
Aspose.Words.Cloud.Sdk.Model.CommentInsert commentInsert = new Aspose.Words.Cloud.Sdk.Model.CommentInsert() | |
{ | |
Initial = "Aspose", | |
Author = "Nayyer Shahbaz", | |
RangeStart = documentPosition, | |
RangeEnd = documentPosition, | |
Text = "Comment added through API" | |
}; | |
// create an object of GetCommentRequest where we pass input file name and comment index value | |
Aspose.Words.Cloud.Sdk.Model.Requests.InsertCommentRequest request = | |
new Aspose.Words.Cloud.Sdk.Model.Requests.InsertCommentRequest(filename, commentInsert, null, null, null); | |
// create an instance of CommentResponse and read comment from document | |
Aspose.Words.Cloud.Sdk.Model.CommentResponse response = wordsApi.InsertComment(request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string clientID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string clientSecret = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(clientID, clientSecret); | |
// input file name | |
String filename = "Volume 1.docx"; | |
// index of comment | |
int commentIndex = 0; | |
Aspose.Words.Cloud.Sdk.Model.Requests.DeleteCommentRequest request = | |
new Aspose.Words.Cloud.Sdk.Model.Requests.DeleteCommentRequest(filename, commentIndex, null, null, null, null, null, null, null); | |
wordsApi.DeleteComment(request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string clientID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string clientSecret = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(clientID, clientSecret); | |
// input file name | |
String filename= "Volume 1.docx"; | |
// index of comment | |
int commentIndex = 0; | |
// create an object of GetCommentRequest where we pass input file name and comment index value | |
Aspose.Words.Cloud.Sdk.Model.Requests.GetCommentRequest request = new Aspose.Words.Cloud.Sdk.Model.Requests.GetCommentRequest(filename, commentIndex, null, null, null, null); | |
// create an instance of CommentResponse and read comment from document | |
Aspose.Words.Cloud.Sdk.Model.CommentResponse response = wordsApi.GetComment(request); | |
// display the comment in console | |
Console.Write(response.Comment); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string clientID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string clientSecret = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(clientID, clientSecret); | |
// input file name | |
String filename = "EmptyHtmlFile.html"; | |
String format = "docx"; | |
String destinationFile = "myResultant.docx"; | |
Aspose.Words.Cloud.Sdk.Model.SaveOptionsData saveOptionsData = new Aspose.Words.Cloud.Sdk.Model.SaveOptionsData() | |
{ | |
SaveFormat = format, | |
FileName = destinationFile | |
}; | |
Aspose.Words.Cloud.Sdk.Model.Requests.SaveAsRequest request = | |
new Aspose.Words.Cloud.Sdk.Model.Requests.SaveAsRequest(filename, saveOptionsData, null, null, null, null, null); | |
Aspose.Words.Cloud.Sdk.Model.SaveResponse result = wordsApi.SaveAs(request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
string MyAppSid = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// create an object of WordsAPI while passing AppKey and AppSid information | |
WordsApi wordsApi = new WordsApi(MyAppKey, MyAppSid); | |
// upload sample document to cloud storage | |
wordsApi.UploadFile(new UploadFileRequest(new System.IO.FileStream("/Users/nayyershahbaz/Documents/BusinessLetter.docx", | |
FileMode.Open, FileAccess.Read), "BusinessLetter.docx")); | |
// Insert Header Object on first page | |
var putHeaderFooterRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.InsertHeaderFooterRequest("BusinessLetter.docx", "HeaderFirst", null,null); | |
var actual = wordsApi.InsertHeaderFooter(putHeaderFooterRequest); | |
// Create Run object containing sample text | |
var run = new Run { Text = "Aspose.Words Cloud SDK for .NET " }; | |
// add the Run text to first paragraph of first HeaderFooter object in first section of Word document | |
var runRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.InsertRunRequest("BusinessLetter.docx", "sections/0/headersfooters/1/paragraphs/0", run); | |
// Insert the RunRequest to Word Document | |
var actual2 = wordsApi.InsertRun(runRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
string MyAppSid = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
public class AppendaDocument | |
{ | |
public static void Run() | |
{ | |
WordsApi wordsApi = new WordsApi(MyAppKey,MyAppSid); | |
try | |
{ | |
string fileName = "Working with Header_Footer Objects.docx"; | |
string documentToAppend = "Another sample file.docx"; | |
// string folder = ""; // File exists at the root of the storage | |
string destName = "Out_Merged.docx"; // // Changes will be made in the source document | |
var body = new Aspose.Words.Cloud.Sdk.Model.DocumentEntryList(); | |
System.Collections.Generic.List<Aspose.Words.Cloud.Sdk.Model.DocumentEntry> docEntries = new System.Collections.Generic.List<Aspose.Words.Cloud.Sdk.Model.DocumentEntry>(); | |
Aspose.Words.Cloud.Sdk.Model.DocumentEntry docEntry = new Aspose.Words.Cloud.Sdk.Model.DocumentEntry { Href = documentToAppend, ImportFormatMode = "KeepSourceFormatting" }; | |
docEntries.Add(docEntry); | |
body.DocumentEntries = docEntries; | |
Aspose.Words.Cloud.Sdk.Model.Requests.AppendDocumentRequest request = new Aspose.Words.Cloud.Sdk.Model.Requests.AppendDocumentRequest(fileName, body, null, null,null,null, destName, null, null); | |
Aspose.Words.Cloud.Sdk.Model.DocumentResponse result = wordsApi.AppendDocument(request); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e.ToString()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string clientID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string clientSecret = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(clientID, clientSecret); | |
// input file name | |
String filename = "Volume 1.docx"; | |
// index of comment | |
int commentIndex = 1; | |
Aspose.Words.Cloud.Sdk.Model.NodeLink link = new Aspose.Words.Cloud.Sdk.Model.NodeLink() | |
{ | |
NodeId = "0.1.0.1.1.1.1" | |
}; | |
Aspose.Words.Cloud.Sdk.Model.DocumentPosition documentPosition = new Aspose.Words.Cloud.Sdk.Model.DocumentPosition() | |
{ | |
Node = link, | |
Offset = 0 | |
}; | |
Aspose.Words.Cloud.Sdk.Model.CommentUpdate commentUpdate = new Aspose.Words.Cloud.Sdk.Model.CommentUpdate() | |
{ | |
Initial = "Aspose", | |
Author = "Nayyer Shahbaz", | |
RangeStart = documentPosition, | |
RangeEnd = documentPosition, | |
Text = "Comments updated using Aspose.Words Cloud API" | |
}; | |
// create an object of GetCommentRequest where we pass input file name and comment index value | |
Aspose.Words.Cloud.Sdk.Model.Requests.UpdateCommentRequest request = | |
new Aspose.Words.Cloud.Sdk.Model.Requests.UpdateCommentRequest(filename, commentIndex, commentUpdate, null, null, null); | |
// create an instance of CommentResponse and read comment from document | |
Aspose.Words.Cloud.Sdk.Model.CommentResponse response = wordsApi.UpdateComment(request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
string MyAppSid = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// create an object of WordsAPI while passing AppKey and AppSid information | |
WordsApi wordsApi = new WordsApi(MyAppKey, MyAppSid); | |
// upload sample document to cloud storage | |
wordsApi.UploadFile(new UploadFileRequest(new System.IO.FileStream("/Users/nayyershahbaz/Documents/BusinessLetter.docx", | |
FileMode.Open, FileAccess.Read), "BusinessLetter.docx")); | |
// The next step is to set formatting of Header Object | |
var runIndex = 0; | |
var fontDto = new Font { Bold = true, Name = "Verdana", Size = 16, Color = new XmlColor { Web = "#e0a50d" } }; | |
// Set formatting of text as Engrave | |
fontDto.Engrave = true; | |
// Apply formatting to first paragraph of HeaderFooter object | |
var documentParagraphRunFontRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UpdateRunFontRequest("BusinessLetter.docx", | |
fontDto, "sections/0/headersfooters/1/paragraphs/0", runIndex); | |
var actual4 = wordsApi.UpdateRunFont(documentParagraphRunFontRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string appSID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string appKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(appSID, appKey); | |
Aspose.Words.Cloud.Sdk.Model.Requests.ConvertDocumentRequest request = new Aspose.Words.Cloud.Sdk.Model.Requests.ConvertDocumentRequest(File.OpenRead("/Users/myIput.doc"), "pdf", null, null, null); | |
// perform the document conversion | |
Stream result = wordsApi.ConvertDocument(request); | |
// specify the location for resultant file and write the document | |
using (Stream file = File.Create("/users/MyConversion.pdf")) | |
{ | |
CopyStream(result, file); | |
} | |
public static void CopyStream(Stream input, Stream output) | |
{ | |
byte[] buffer = new byte[8 * 1024]; | |
int len; | |
while ((len = input.Read(buffer, 0, buffer.Length)) > 0) | |
{ | |
output.Write(buffer, 0, len); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string appSID = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
const string appKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/ | |
// initialize and object of WordsApi | |
Aspose.Words.Cloud.Sdk.WordsApi wordsApi = new Aspose.Words.Cloud.Sdk.WordsApi(appSID, appKey); | |
// load input MS Word document into Stream instance | |
using (var inputStream = new FileStream("/Users/Office-User.docx", FileMode.Open)) | |
{ | |
var uploadFileRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(inputStream, "fileStoredInCloud.doc"); | |
wordsApi.UploadFile(uploadFileRequest); | |
} | |
// specify resultant file format and name | |
var saveOptionsData = new Aspose.Words.Cloud.Sdk.Model.SaveOptionsData { SaveFormat = "pdf", FileName = "destStoredInCloud.pdf" }; | |
// specify the input Word document path and saveoptions details | |
var saveRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.SaveAsRequest("fileStoredInCloud.doc", saveOptionsData); | |
// method to start document conversion | |
wordsApi.SaveAs(saveRequest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment