为 PDF 或 Word 文件添加水印或使用 PHP 删除以前添加的水印

借助此 PHP 库,开发人员可以在 PDF 或 Word 文档上添加图像或文本水印,并在几秒钟内删除已添加的水印

保护您的文档免遭未经授权的分发并在线添加水印。为此,只需加载 PDF、Word 或其他文档格式并使用 PHP 添加文本或图像水印。然后以方便的格式保存带水印的 PDF 或 Word 文档,例如 DOC、DOCX、PDF、HTML、RTF、XPS 等。您还可以从文档中删除水印,以使其更易于处理,除非它侵犯了任何人的权利。

查看代码片段

在 PHP 中添加水印

使用此 PHP API,开发人员可以在线为 PDF、Word 或其他文档添加水印。您可以使用文本或图像创建水印,然后通过在 PHP 中设置叠加角度将该水印插入 PDF 或 Word 文档。

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

去除 PHP 中的水印

给定的 PHP SDK 也有助于去除水印。例如,在 Word 中删除水印意味着您可以加载带有文本或图像水印标记的所需 Word 文档,使用 PHP 从文档中删除此水印,然后以方便的格式保存输出文件。

Word 或 PDF 中的水印

要评估我们的 PHP API,请加载要添加水印的文档,并将水印作为图像或文本加载。然后选择一种方便的导出文件格式--DOCX、PDF、MD、HTML、TXT、DOC、RTF、EPUB、XPS 等。

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

文件需要加水印
运行代码
上传要插入的图片
从列表中选择目标格式
use Aspose\Words\WordsApi;

$wordsApi = new WordsApi('####-####-####-####-####', '##################');

$requestDocument = "Input1.docx";
$requestImageFile = "Input2.docx";
$insertWatermarkImageOnline = new InsertWatermarkImageOnlineRequest(
    $requestDocument, $requestImageFile, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
$insertedWatermarkImage = $wordsApi->insertWatermarkImageOnline($insertWatermarkImageOnline);

$convertDocument = new ConvertDocumentRequest(
    $insertedWatermarkImage->document()->values(), "docx", 
	   NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
$wordsApi->convertDocument($convertDocument);
use Aspose\Words\WordsApi;

$wordsApi = new WordsApi('####-####-####-####-####', '##################');

$requestDocument = "Input.docx";
$requestWatermarkText = new WatermarkText(array(
    "text" => "This is the watermark text.",
    "rotation_angle" => 90,
));
$insertWatermarkTextOnline = new InsertWatermarkTextOnlineRequest(
    $requestDocument, $requestWatermarkText, NULL, NULL, NULL, NULL, NULL, NULL
);
$insertedWatermarkText = $wordsApi->insertWatermarkTextOnline($insertWatermarkTextOnline);

$convertDocument = new ConvertDocumentRequest(
    $insertedWatermarkText->document()->values(), "docx", 
	   NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
$wordsApi->convertDocument($convertDocument);
use Aspose\Words\WordsApi;

$wordsApi = new WordsApi('####-####-####-####-####', '##################');

$requestDocument = "Input.docx";
$deleteWatermarkOnline = new DeleteWatermarkOnlineRequest(
    $requestDocument, NULL, NULL, NULL, NULL, NULL, NULL
);
$deletedWatermark = $wordsApi->deleteWatermarkOnline($deleteWatermarkOnline);

$convertDocument = new ConvertDocumentRequest(
    $deletedWatermark->document()->values(), "docx", NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
$wordsApi->convertDocument($convertDocument);
运行代码
  
将代码PHP复制到剪贴板

如何去除 PHP 中的水印

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

PHP 库使用水印

Packagist 存储库安装 'Aspose.Words Cloud SDK for PHP' 。只需运行 composer require aspose-cloud/aspose-words-cloud 来安装 SDK,然后使用 require_once('vendor/autoload.php'); 将其导入您的项目。

作为替代方案,您可以从 GitHub 手动克隆 Aspose.Words Cloud SDK for PHP 源代码。请按照这些 Instructions 快速获取必要的安全凭证并访问我们的 REST API。

系统要求

PHP 7.1 或更新版本

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

添加水印的最流行的文档格式

5%

订阅 Aspose 产品更新

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

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