Last active
February 9, 2021 05:27
-
-
Save groupdocscloud/90da27f305908428852e34cf1ed77ad0 to your computer and use it in GitHub Desktop.
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
Watermark-CSharp |
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 MyClientId = "YOUR-CLIENT-ID"; | |
string MyClientSecret = "YOUR-CLIENT-SECRET"; | |
var config = new Configuration(MyClientId, MyClientSecret); | |
var watermarkApi = new WatermarkApi(config); | |
var fileApi = new FileApi(config); | |
var storageApi = new StorageApi(config); |
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
// 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); |
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
// 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); |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
var downloadRequest = new DownloadFileRequest(file, MyStorage); | |
Stream downloadResponse = fileApi.DownloadFile(downloadRequest); | |
using (var fileStream = System.IO.File.Create("C:\\Files\\DownloadedFile.pdf")) | |
{ | |
downloadResponse.Seek(0, SeekOrigin.Begin); | |
downloadResponse.CopyTo(fileStream); | |
} |
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
public static string FindAndReplaceImageWatermark(WatermarkApi watermarkApi) | |
{ | |
var options = new ReplaceOptions | |
{ | |
FileInfo = new GroupDocs.Watermark.Cloud.Sdk.Model.FileInfo | |
{ | |
FilePath = "Sample.pdf" | |
}, | |
ImageSearchCriteria = new ImageSearchCriteria | |
{ | |
ImageFileInfo = new GroupDocs.Watermark.Cloud.Sdk.Model.FileInfo | |
{ | |
FilePath = "sample_watermark.png" | |
} | |
}, | |
ReplaceImageOptions = new ReplaceImageOptions | |
{ | |
Image = new GroupDocs.Watermark.Cloud.Sdk.Model.FileInfo | |
{ | |
FilePath = "Logo.png" | |
} | |
} | |
}; | |
var request = new ReplaceRequest(options); | |
var result = watermarkApi.Replace(request); | |
return result.Path; | |
} |
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
ReplaceTextOptions = new ReplaceTextOptions | |
{ | |
Text = "Confidential", | |
FontFamily = "Arial", | |
Size = 20d, | |
ForegroundColor = new Color { A = 0, R = 0, G = 100, B = 0 } | |
} |
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
public static string FindAndReplaceTextWatermark(WatermarkApi watermarkApi) | |
{ | |
var options = new ReplaceOptions | |
{ | |
FileInfo = new GroupDocs.Watermark.Cloud.Sdk.Model.FileInfo | |
{ | |
FilePath = "Sample.pdf" | |
}, | |
TextSearchCriteria = new TextSearchCriteria | |
{ | |
SearchText = "Watermark Text" | |
}, | |
ReplaceTextOptions = new ReplaceTextOptions | |
{ | |
Text = "Confidential", | |
} | |
}; | |
var request = new ReplaceRequest(options); | |
var result = watermarkApi.Replace(request); | |
return result.Path; | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
// 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(); |
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
// 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); |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
// 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); |
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
// 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); |
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
// 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); |
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
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); | |
} | |
} | |
} | |
} |
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
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); | |
} | |
} | |
} | |
} |
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
var path = @"C:\Files\"; | |
string MyStorage = null; | |
var file = Directory.GetFiles(path, "Sample.pdf", SearchOption.AllDirectories).FirstOrDefault(); | |
if (file.Length != 0) | |
{ | |
var relativeFilePath = file.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar); | |
var fileStream = File.Open(file, FileMode.Open); | |
fileApi.UploadFile(new UploadFileRequest(relativeFilePath, fileStream, MyStorage)); | |
fileStream.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment