Skip to content

Instantly share code, notes, and snippets.

@groupdocscloud
Last active December 9, 2019 14:35
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 groupdocscloud/34f0df87ff6e7aaffef5876bdcb04a38 to your computer and use it in GitHub Desktop.
Save groupdocscloud/34f0df87ff6e7aaffef5876bdcb04a38 to your computer and use it in GitHub Desktop.
Editor-CSharp-v2
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Copy File
class Copy_File
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FileApi(configuration);
try
{
var request = new CopyFileRequest("WordProcessing/one-page.docx", "WordProcessing/one-page-copied.docx", Common.MyStorage, Common.MyStorage);
apiInstance.CopyFile(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing/one-page.docx' file copied as 'WordProcessing/one-page-copied.docx'.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FileApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Copy Folder
class Copy_Folder
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FolderApi(configuration);
try
{
var request = new CopyFolderRequest("WordProcessing", "WordProcessing1", Common.MyStorage, Common.MyStorage);
apiInstance.CopyFolder(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing' folder copied as 'WordProcessing1'.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FolderApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Create Folder
class Create_Folder
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FolderApi(configuration);
try
{
var request = new CreateFolderRequest("", Common.MyStorage);
apiInstance.CreateFolder(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing' folder created.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FolderApi: " + e.Message);
}
}
}
}
// For complete examples and data files, please go to https://github.com/groupdocs-parser-cloud/groupdocs-parser-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
var apiInstance = new TemplateApi(configuration);
var template = new Template
{
Fields = new List<Field>
{
new Field
{
FieldName = "Address",
FieldPosition = new FieldPosition
{
FieldPositionType = "Regex",
Regex = "Company address:"
}
},
new Field
{
FieldName = "CompanyAddress",
FieldPosition = new FieldPosition
{
FieldPositionType = "Linked",
LinkedFieldName = "ADDRESS",
IsRightLinked = true,
SearchArea = new Size { Height = 10, Width = 100 },
AutoScale = true
}
},
new Field
{
FieldName = "Company",
FieldPosition = new FieldPosition
{
FieldPositionType = "Regex",
Regex = "Company name:"
}
},
new Field
{
FieldName = "CompanyName",
FieldPosition = new FieldPosition
{
FieldPositionType = "Linked",
LinkedFieldName = "Company",
IsRightLinked = true,
SearchArea = new Size { Height = 10, Width = 100 },
AutoScale = true
}
}
},
Tables = new List<Table>
{
new Table
{
TableName = "Companies",
DetectorParameters = new DetectorParameters
{
Rectangle = new Rectangle
{
Position = new Point
{
X = 77,
Y = 279
},
Size = new Size
{
Height = 60,
Width = 480
}
}
}
}
}
};
var options = new CreateTemplateOptions
{
Template = template,
TemplatePath = "templates/template_2.json"
};
var request = new CreateTemplateRequest(options);
var response = apiInstance.CreateTemplate(request);
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Delete File
class Delete_File
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FileApi(configuration);
try
{
var request = new DeleteFileRequest("WordProcessing1/one-page.docx", Common.MyStorage);
apiInstance.DeleteFile(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing1/one-page.docx' deleted.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FileApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Delete Folder
class Delete_Folder
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FolderApi(configuration);
try
{
var request = new DeleteFolderRequest("WordProcessing/WordProcessing1", Common.MyStorage, true);
apiInstance.DeleteFolder(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing/WordProcessing1' folder deleted recusrsively.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FolderApi: " + e.Message);
}
}
}
}
// For complete examples and data files, please go to https://github.com/groupdocs-parser-cloud/groupdocs-parser-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
var apiInstance = new TemplateApi(configuration);
var options = new TemplateOptions
{
TemplatePath = "templates/template-for-companies.json"
};
var request = new DeleteTemplateRequest(options);
var response = apiInstance.DeleteTemplate(request);
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
using System.IO;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Download_File
class Download_File
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FileApi(configuration);
try
{
var request = new DownloadFileRequest("WordProcessing/ten-pages.pdf", Common.MyStorage);
Stream response = apiInstance.DownloadFile(request);
using (var fileStream = File.Create("D:\\tenpages.pdf"))
{
response.Seek(0, SeekOrigin.Begin);
response.CopyTo(fileStream);
}
Console.WriteLine("Expected response type is Stream: " + response.Length.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FileApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Get Get Disc Usage
class Get_Disc_Usage
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new StorageApi(configuration);
try
{
var request = new GetDiscUsageRequest(Common.MyStorage);
var response = apiInstance.GetDiscUsage(request);
Console.WriteLine("Expected response type is DiscUsage: " + response.UsedSize.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling StorageApi: " + e.Message);
}
}
}
}
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
var apiInstance = new InfoApi(configuration);
var response = apiInstance.GetSupportedFileFormats();
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
var apiInstance = new InfoApi(configuration);
var fileInfo = new FileInfo
{
FilePath = "wordprocessing/four-pages.docx",
Password = "password",
StorageName = Common.MyStorage
};
var request = new GetInfoRequest(fileInfo);
var response = apiInstance.GetInfo(request);
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Get File Versions
class Get_File_Versions
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new StorageApi(configuration);
try
{
var request = new GetFileVersionsRequest("one-page.docx", Common.MyStorage);
var response = apiInstance.GetFileVersions(request);
Console.WriteLine("Expected response type is FileVersions: " + response.Value.Count.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling StorageApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Get Files List
class Get_Files_List
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FolderApi(configuration);
try
{
var request = new GetFilesListRequest("WordProcessing", Common.MyStorage);
var response = apiInstance.GetFilesList(request);
Console.WriteLine("Expected response type is FilesList: " + response.Value.Count.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FolderApi: " + e.Message);
}
}
}
}
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Move File
class Move_File
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FileApi(configuration);
try
{
var request = new MoveFileRequest("WordProcessing/one-page.docx", "WordProcessing1/one-page.docx", Common.MyStorage, Common.MyStorage);
apiInstance.MoveFile(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing/one-page.docx' file moved to 'WordProcessing1/one-page.docx'.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FileApi: " + e.Message);
}
}
}
}
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Move Folder
class Move_Folder
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FolderApi(configuration);
try
{
var request = new MoveFolderRequest("WordProcessing1", "WordProcessing\\WordProcessing1", Common.MyStorage, Common.MyStorage);
apiInstance.MoveFolder(request);
Console.WriteLine("Expected response type is Void: 'WordProcessing1' folder moved to 'WordProcessing/WordProcessing1'.");
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FolderApi: " + e.Message);
}
}
}
}
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
using System;
using FileInfo = GroupDocs.Editor.Cloud.Sdk.Model.FileInfo;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
/// <summary>
/// This example demonstrates how to move document page to a new position.
/// </summary>
public class MovePage
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new PagesApi(configuration);
try
{
var fileInfo = new FileInfo
{
FilePath = "WordProcessing/four-pages.docx"
};
var options = new MoveOptions
{
FileInfo = fileInfo,
OutputPath = "Output/move-pages.docx",
PageNumber = 1,
NewPageNumber = 2
};
var request = new MoveRequest(options);
var response = apiInstance.Move(request);
Console.WriteLine("Output file path: " + response.Path);
}
catch (Exception e)
{
Console.WriteLine("Exception while calling api: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Is Object Exists
class Object_Exists
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new StorageApi(configuration);
try
{
var request = new ObjectExistsRequest("WordProcessing/one-page.docx", Common.MyStorage);
var response = apiInstance.ObjectExists(request);
Console.WriteLine("Expected response type is ObjectExist: " + response.Exists.Value.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling StorageApi: " + e.Message);
}
}
}
}
using System;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Is Storage Exist
class Storage_Exist
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new StorageApi(configuration);
try
{
var request = new StorageExistsRequest(Common.MyStorage);
var response = apiInstance.StorageExists(request);
Console.WriteLine("Expected response type is StorageExist: " + response.Exists.Value.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling StorageApi: " + e.Message);
}
}
}
}
using System;
using System.IO;
using GroupDocs.Editor.Cloud.Sdk.Api;
using GroupDocs.Editor.Cloud.Sdk.Client;
using GroupDocs.Editor.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Editor.Cloud.Examples.CSharp
{
// Upload File
class Upload_File
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new FileApi(configuration);
try
{
// Open file in IOStream from local/disc.
var fileStream = File.Open("..\\..\\..\\Data\\WordProcessing\\one-page.docx", FileMode.Open);
var request = new UploadFileRequest("WordProcessing/one-page.docx", fileStream, Common.MyStorage);
var response = apiInstance.UploadFile(request);
Console.WriteLine("Expected response type is FilesUploadResult: " + response.Uploaded.Count.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling FileApi: " + e.Message);
}
}
}
}
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
// The document already uploaded into the storage.
// Load it into editable state
var loadOptions = new DelimitedTextLoadOptions
{
FileInfo = new FileInfo
{
FilePath = "Spreadsheet/sample.tsv"
},
OutputPath = "output"
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
// Download html document
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
// Edit something...
htmlString = htmlString.Replace("32", "66");
// Upload html back to storage
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
// Save html back to tsv
var saveOptions = new DelimitedTextSaveOptions
{
FileInfo = loadOptions.FileInfo,
OutputPath = "output/edited.tsv",
HtmlPath = loadResult.HtmlPath,
ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
// The document already uploaded into the storage.
// Load it into editable state
var loadOptions = new PresentationLoadOptions
{
FileInfo = new FileInfo
{
FilePath = "Presentation/with-notes.pptx"
},
OutputPath = "output",
SlideNumber = 0
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
// Download html document
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
// Edit something...
htmlString = htmlString.Replace("Slide sub-heading", "Hello world!");
// Upload html back to storage
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
// Save html back to pptx
var saveOptions = new PresentationSaveOptions
{
FileInfo = loadOptions.FileInfo,
OutputPath = "output/edited.pptx",
HtmlPath = loadResult.HtmlPath,
ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
// The document already uploaded into the storage.
// Load it into editable state
var loadOptions = new SpreadsheetLoadOptions
{
FileInfo = new FileInfo
{
FilePath = "Spreadsheet/four-sheets.xlsx"
},
OutputPath = "output",
WorksheetIndex = 0
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
// Download html document
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
// Edit something...
htmlString = htmlString.Replace("This is sample sheet", "This is sample sheep");
// Upload html back to storage
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
// Save html back to xlsx
var saveOptions = new SpreadsheetSaveOptions
{
FileInfo = loadOptions.FileInfo,
OutputPath = "output/edited.xlsx",
HtmlPath = loadResult.HtmlPath,
ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
// The document already uploaded into the storage.
// Load it into editable state
var loadOptions = new TextLoadOptions
{
FileInfo = new FileInfo
{
FilePath = "Text/document.txt"
},
OutputPath = "output"
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
// Download html document
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
// Edit something...
htmlString = htmlString.Replace("Page Text", "New Text");
// Upload html back to storage
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
// Save html back to txt
var saveOptions = new TextSaveOptions
{
FileInfo = loadOptions.FileInfo,
OutputPath = "output/edited.txt",
HtmlPath = loadResult.HtmlPath,
ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));
// For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-dotnet-samples
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
var configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
var editApi = new EditApi(configuration );
var fileApi = new FileApi(configuration );
// The document already uploaded into the storage.
// Load it into editable state
var loadOptions = new WordProcessingLoadOptions
{
FileInfo = new FileInfo
{
FilePath = "WordProcessing/password-protected.docx",
Password = "password"
},
OutputPath = "output"
};
var loadResult = editApi.Load(new LoadRequest(loadOptions));
// Download html document
var stream = fileApi.DownloadFile(new DownloadFileRequest(loadResult.HtmlPath));
var htmlString = new StreamReader(stream, Encoding.UTF8).ReadToEnd();
// Edit something...
htmlString = htmlString.Replace("Sample test text", "Hello world");
// Upload html back to storage
fileApi.UploadFile(new UploadFileRequest(loadResult.HtmlPath,
new MemoryStream(Encoding.UTF8.GetBytes(htmlString))));
// Save html back to docx
var saveOptions = new WordProcessingSaveOptions
{
FileInfo = loadOptions.FileInfo,
OutputPath = "output/edited.docx",
HtmlPath = loadResult.HtmlPath,
ResourcesPath = loadResult.ResourcesPath
};
var saveResult = editApi.Save(new SaveRequest(saveOptions));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment