向 DOCX 添加水印或使用 Ruby 删除以前添加的水印

使用此 Ruby 库,在 DOCX 文档上添加图像或文本水印或通过几个步骤删除已添加的水印

使用 Ruby 将文本或图像水印添加到 DOCX 文档。加载 DOCX 文档并将所需的水印插入其中。然后将结果保存为 DOCX、PDF、MD、HTML、TXT、DOC、RTF、EPUB、XPS 等方便的格式,并与他人共享带水印的文档。如果之前已将水印添加到文档中,并且添加的原因不再相关,则还要从 DOCX 文档中删除水印。

查看代码片段

DOCX – 在 Ruby 中添加水印

使用此 Ruby API,开发人员可以在线向 DOCX 添加水印。只需使用文本或图像创建水印,然后将该水印插入到 Ruby 中的 DOCX 文档中。

注意:无需安装任何第三方应用程序或库。因此,我们的 Ruby 软件解决方案非常易于使用。

从 DOCX 中删除水印 – Ruby

给定的 Ruby SDK 也有助于从 DOCX 中删除水印。删除 DOCX 中的水印意味着您可以加载带有文本或图像水印标记的所需 DOCX 文档,使用 Ruby 从 DOCX 中删除此水印,然后以方便的格式保存输出文件 - DOC、DOCX、PDF、JPEG、 PNG、TIFF 等。

在 DOCX 中使用水印

要评估如何使用我们的 Ruby API 在 DOCX 中添加或删除水印,请将 DOCX 和水印作为图像或文本加载。然后选择一种方便的导出文件格式--DOC、DOCX、PDF、HTML、RTF、XPS 等。

使用以下示例查看其工作原理:

文件需要加水印
运行代码
上传要插入的图片
从列表中选择目标格式
require 'aspose_words_cloud'

AsposeWordsCloud.configure do |config|
  config.client_data['ClientId'] = '####-####-####-####-####'
  config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new

request_document = File.open('Input1.docx')
request_image_file = File.open('Input2.docx')
insert_watermark_image_online = InsertWatermarkImageOnlineRequest.new(
   document: request_document, image_file: request_image_file)
inserted_watermark_image = 
   @words_api.insert_watermark_image_online(insert_watermark_image_online)

request_document = File.open('document')
convert_document = ConvertDocumentRequest.new(
   document: inserted_watermark_image.document.values[0], format: 'docx')
@words_api.convert_document(convert_document)
require 'aspose_words_cloud'

AsposeWordsCloud.configure do |config|
  config.client_data['ClientId'] = '####-####-####-####-####'
  config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new

request_document = File.open('Input.docx')
request_watermark_text = WatermarkText.new(
   {:Text => 'This is the watermark text.', :RotationAngle => 90})
insert_watermark_text_online = InsertWatermarkTextOnlineRequest.new(
   document: request_document, watermark_text: request_watermark_text)
inserted_watermark_text = @words_api.insert_watermark_text_online(insert_watermark_text_online)

request_document = File.open('document')
convert_document = ConvertDocumentRequest.new(
   document: inserted_watermark_text.document.values[0], format: 'docx')
@words_api.convert_document(convert_document)
require 'aspose_words_cloud'

AsposeWordsCloud.configure do |config|
  config.client_data['ClientId'] = '####-####-####-####-####'
  config.client_data['ClientSecret'] = '##################'
end
@words_api = WordsAPI.new

request_document = File.open('Input.docx')
delete_watermark_online = DeleteWatermarkOnlineRequest.new(document: request_document)
deleted_watermark = @words_api.delete_watermark_online(delete_watermark_online)

convert_document = ConvertDocumentRequest.new(
   document: deleted_watermark.document.values[0], format: 'docx')
@words_api.convert_document(convert_document)
运行代码
  
将代码Ruby复制到剪贴板

如何使用 Ruby 去除 DOCX 中的水印

  1. Aspose.Words Cloud for Ruby
  2. 将库引用(导入库)添加到您的 Ruby 项目
  3. 使用您的应用密钥配置 API
  4. 加载您要从中删除水印的 DOCX 个文档
  5. 创建删除水印的请求
  6. 将结果保存为方便的文件格式

Ruby 库以在 DOCX 中使用水印

使用 RubyGems 托管服务安装 Aspose.Words Cloud SDK for Ruby 。运行 gem install aspose_words_cloud 来安装包。作为替代方案,您可以从 GitHub 手动克隆 Aspose.Words Cloud SDK for Ruby 源代码并在您的项目中使用它。请按照这些 Instructions 快速获取必要的安全凭证并访问我们的 REST API。

系统要求

Ruby 2.6 或更新版本

请参阅 Repository Documentation 以查看详细信息。

其他支持的文件格式

您可以为其他格式的文档添加水印:

5%

订阅 Aspose 产品更新

获取直接发送到您的邮箱的每月通讯和优惠。

© Aspose Pty Ltd 2001-2024. 版权所有。