Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Watermark-CSharp
// For complete examples and data files, please go to https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-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 ParseApi(configuration);
var fileInfo = new FileInfo
{
FilePath = "documents/sample.docx",
};
var options = new WatermarkOptions()
{
FileInfo = fileInfo,
WatermarkDetails = new List<WatermarkDetails>
{
new WatermarkDetails
{
ImageWatermarkOptions = new ImageWatermarkOptions()
{
Image = new FileInfo { FilePath = "watermark_images/sample_watermark.png" }
}
}
},
ProtectLevel = WatermarkOptions.ProtectLevelEnum.DocumentAndImages
};
var request = new AddRequest(options);
var response = apiInstance.Add(request);
// For complete examples and data files, please go to https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-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 ParseApi(configuration);
var fileInfo = new FileInfo
{
FilePath = "documents/sample.docx"
};
var options = new WatermarkOptions()
{
FileInfo = fileInfo,
WatermarkDetails = new List<WatermarkDetails>
{
new WatermarkDetails
{
TextWatermarkOptions = new TextWatermarkOptions
{
Text = "New watermark text",
FontFamilyName = "Arial",
FontSize = 12d,
}
}
}
};
var request = new AddRequest(options);
var response = apiInstance.Add(request);
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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);
}
}
}
}
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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);
}
}
}
}
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
using System;
using System.IO;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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-watermark-cloud/groupdocs-watermark-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-watermark-cloud/groupdocs-watermark-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 = "documents/password-protected.docx",
Password = "password"
};
var options = new InfoOptions()
{
FileInfo = fileInfo
};
var request = new GetInfoRequest(options);
var response = apiInstance.GetInfo(request);
using System;
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
using System;
namespace GroupDocs.Watermark.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 System;
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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);
}
}
}
}
// For complete examples and data files, please go to https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-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 = "with_watermarks/sample.pdf",
};
var options = new RemoveOptions
{
FileInfo = fileInfo,
ImageSearchCriteria = new ImageSearchCriteria
{
ImageFileInfo = new FileInfo { FilePath = "watermark_images/sample_watermark.png" }
},
TextSearchCriteria = new TextSearchCriteria
{
SearchText = "Watermark text"
},
OutputFolder = "removed_watermarks"
};
var request = new RemoveRequest(options);
var response = apiInstance.Remove(request);
// For complete examples and data files, please go to https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-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 = "with_watermarks/sample.pdf",
};
var options = new ReplaceOptions
{
FileInfo = fileInfo,
ImageSearchCriteria = new ImageSearchCriteria
{
ImageFileInfo = new FileInfo { FilePath = "watermark_images/sample_watermark.png" }
},
TextSearchCriteria = new TextSearchCriteria
{
SearchText = "Watermark text"
},
ReplaceTextOptions = new ReplaceTextOptions
{
Text = "New watermark text",
},
ReplaceImageOptions = new ReplaceImageOptions
{
Image = new FileInfo { FilePath = "images/sample.jpg" }
}
};
var request = new ReplaceRequest(options);
var response = apiInstance.Replace(request);
// 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 InfoApi(configuration);
var fileInfo = new FileInfo
{
FilePath = "with_watermarks/sample.pdf"
};
var options = new SearchOptions
{
FileInfo = fileInfo,
ImageSearchCriteria = new ImageSearchCriteria
{
ImageFileInfo = new FileInfo { FilePath = "watermark_images/sample_watermark.png" }
},
TextSearchCriteria = new TextSearchCriteria
{
SearchText = "Watermark text"
},
SaveFoundImages = true,
OutputFolder = "found_image_watermarks"
};
var request = new SearchRequest(options);
var response = apiInstance.Search(request);
using System;
using GroupDocs.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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.Watermark.Cloud.Sdk.Api;
using GroupDocs.Watermark.Cloud.Sdk.Client;
using GroupDocs.Watermark.Cloud.Sdk.Model.Requests;
namespace GroupDocs.Watermark.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);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.