GroupDocs.Watermark Cloud SDK for .NET 使你能够以编程方式管理多种文档格式(包括:PDF、Microsoft Word、Excel、PowerPoint、Visio、OpenDocument、JPEG、BMP、PNG、TIFF 等)的文本和图像水印。 它支持所有最常用的水印方法,让你可以在受支持格式的图像和文档中添加、移除、搜索和替换水印。即使是文档中已存在的旧水印,也可以被移除,无论它们是否由第三方工具添加。只需少量代码或几行指令,即可通过调整文本样式、字体、大小、颜色或位置,轻松自定义水印格式设置。 GroupDocs.Watermark Cloud SDK for .NET 构建在 GroupDocs.Watermark Cloud REST API 之上,作为一层抽象,使你无需了解 REST API 即可使用此 SDK。
//Get your App SID, App Key and Storage Name at https://dashboard.groupdocs.cloud (free registration is required).
public class AddTextWatermarks
{
public static void Run()
{
var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
var apiInstance = new WatermarkApi(configuration);
try
{
var fileInfo = new FileInfo
{
FilePath = "documents/sample.docx",
StorageName = Common.MyStorage
};
var options = new WatermarkOptions()
{
FileInfo = fileInfo,
WatermarkDetails = new List
{
new WatermarkDetails
{
TextWatermarkOptions = new TextWatermarkOptions
{
Text = "New watermark text",
FontFamilyName = "Arial",
FontSize = 12d,
}
}
}
};
var request = new AddRequest(options);
var response = apiInstance.Add(request);
Console.WriteLine("Resultant file path: " + response.Path);
}
catch (Exception e)
{
Console.WriteLine("Exception while calling WatermarkApi: " + e.Message);
}
}
}
}