云开发者的好消息! GroupDocs 推出了 Watermark Cloud API。这增强了 GroupDocs 水印解决方案。它已经作为 .NET 和 Java 开发人员的本地 API 以及任何类型用户的跨平台在线应用程序 存在。 Watermark Cloud API 和 SDK 允许开发人员使用水印保护重要文档,这些文档很难被第三方工具自动删除。
GroupDocs.Watermark Cloud 是 REST API,提供保护文档和管理水印的所有主要功能。一些重要的功能包括:添加图像或文本水印,删除已添加的水印,替换或搜索所有支持格式的水印。
支持的文档类型
以下是当前支持的文档格式。您可以随时访问 GroupDocs.Watermark Cloud 的文档,以全面了解适用于任何支持的文档格式的特定功能。
SDK 和示例
除了水印REST API,GroupDocs还提供开源SDK,甚至可以根据需求进行自定义。开发人员可以使用相关的SDK来加快开发速度,而无需担心发出请求和处理响应的底层细节。目前,我们已经推出了以下 SDK 以及示例。这些 SDK 和示例也可在 GitHub 上获取:
以下是一些示例,可以帮助您获得更好的想法。如需更多示例,您可以访问[文档][10]页面或访问相关的[GitHub存储库][11]。
Java中为Word文档添加图像水印
您可以在此处查看使用 [GroupDocs.Watermark Cloud SDK for Java][12] 向 Word 文档添加水印的 Java 代码示例。
// 如需完整示例和数据文件,请访问 https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-cloud-java-samples
String MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
String MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
Configuration configuration = new Configuration(MyAppSid, MyAppKey);
WatermarkApi apiInstance = new WatermarkApi(configuration);
WatermarkOptions options = new WatermarkOptions();
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("documents/sample.docx");
options.setFileInfo(fileInfo);
WatermarkDetails watermarkDetails = new WatermarkDetails();
ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
FileInfo image = new FileInfo();
image.setFilePath("watermark_images/sample_watermark.png");
imageWatermarkOptions.setImage(image);
watermarkDetails.setImageWatermarkOptions(imageWatermarkOptions);
List<WatermarkDetails> watermarkDetailsList = new ArrayList<WatermarkDetails>();
watermarkDetailsList.add(watermarkDetails);
options.setWatermarkDetails(watermarkDetailsList);
AddRequest request = new AddRequest(options);
WatermarkResult response = apiInstance.add(request);
C# 中的 PDF 文档去除水印
下面的代码片段展示了如何使用 [GroupDocs.Watermark Cloud SDK for .NET][13] 在 CSharp 中快速删除 PDF 文档中的任何水印。
// 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);
使用 Java 替换 PDF 文档中的水印
以下 Java 示例展示了如何替换已识别的水印属性。水印图像、文本或文本外观选项(如字体、大小、颜色等)可以轻松替换。
// 如需完整示例和数据文件,请访问 https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-cloud-java-samples
String MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
String MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
Configuration configuration = new Configuration(MyAppSid, MyAppKey);
WatermarkApi apiInstance = new WatermarkApi(configuration);
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("with_watermarks/sample.pdf");
ReplaceOptions options = new ReplaceOptions();
options.setFileInfo(fileInfo);
ImageSearchCriteria imageSearchCriteria = new ImageSearchCriteria();
FileInfo imageFileInfo = new FileInfo();
imageFileInfo.setFilePath("watermark_images/sample_watermark.png");
imageSearchCriteria.setImageFileInfo(imageFileInfo);
options.setImageSearchCriteria(imageSearchCriteria);
TextSearchCriteria textSearchCriteria = new TextSearchCriteria();
textSearchCriteria.setSearchText("Watermark text");
options.setTextSearchCriteria(textSearchCriteria);
ReplaceTextOptions replaceTextOptions = new ReplaceTextOptions();
replaceTextOptions.setText("New watermark text");
options.setReplaceTextOptions(replaceTextOptions);
ReplaceImageOptions replaceImageOptions = new ReplaceImageOptions();
FileInfo replaceImageFileInfo = new FileInfo();
replaceImageFileInfo.setFilePath("images/sample.jpg");
replaceImageOptions.setImage(replaceImageFileInfo);
options.setReplaceImageOptions(replaceImageOptions);
options.setOutputFolder("found_image_watermarks");
ReplaceRequest request = new ReplaceRequest(options);
ReplaceResult response = apiInstance.replace(request);
使用 C# 在文档中搜索水印
REST API 提供了一组丰富的搜索条件来查找目标文档中可能的图像和文本水印。
// 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);
资源
以下是相关资源的一些重要链接。即使这样,如果您感到任何困难或困惑,您也可以在[论坛][14]上自由联系我们。
很高兴在这里见到你[水印][15]。
[5]: https://wiki.fileformat.com/image/jpeg/" target="_blank" rel=“noreferrer noopener” aria-label=" (opens in a new tab [6]: https://wiki.fileformat.com/view/pdf/" target="_blank" rel=“noreferrer noopener” aria-label=“PDF (opens in a new tab [7]: https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-cloud-dotnet-samples" target="_blank” rel=“noreferrer noopener” aria-label=".NET Examples (opens in a new tab [8]: https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-cloud-java" target="_blank" rel=“noreferrer noopener” aria-label=“Java SDK (opens in a new tab [9]: https://github.com/groupdocs-watermark-cloud/groupdocs-watermark-cloud-java-samples" target="_blank” rel=“noreferrer noopener” aria-label=“Java Examples (opens in a new tab [10]: https://docs.groupdocs.cloud/watermark [11]: https://github.com/groupdocs-watermark-cloud [12]: https://products.groupdocs.cloud/watermark/java [13]: https://products.groupdocs.cloud/watermark/net [14]: https://forum.groupdocs.cloud/c/watermark [15]: https://en.wikipedia.org/wiki/Watermark