PNG
JPG
BMP
TIFF
PDF
如何通过云端PHP SDK删除PDF中的书签
要从PDF中移除书签,我们将使用 Aspose.PDF Cloud PHP SDK 此云端SDK帮助PHP程序员使用Aspose.PDF REST API开发基于云的PDF创建、注释、编辑和转换应用程序。只需在Aspose for Cloud创建一个账户并获取您的应用程序信息。一旦您拥有App SID和密钥,您就可以开始使用Aspose.PDF Cloud PHP SDK。
Package Manager Console Command
composer install
通过云端PHP删除PDF中的书签步骤
Aspose.PDF Cloud开发者可以轻松地在几行代码中加载和移除PDF中的书签。
- 上传PDF文档
- 从PDF中删除书签
- 下载处理后的PDF文档
使用PHP删除PDF中的书签
private function _create_rest_api() {
$credentials = json_decode(file_get_contents("./Credentials/credentials.json"), true);
$configAuth = new Configuration();
$configAuth->setAppKey($credentials['key']);
$configAuth->setAppSid($credentials['id']);
$this->pdfApi = new PdfApi(null, $configAuth);
}
public function __construct($config) {
$this->configParams = $config;
$this->_create_rest_api();
}
public function uploadDocument() {
$filePath = $this->configParams['LOCAL_FOLDER'] . $this->configParams['PDF_DOCUMENT_NAME'];
$fileData = file_get_contents($filePath);
$response = $this->pdfApi->uploadFile($this->configParams['PDF_DOCUMENT_NAME'], $fileData);
if ($response->getCode() === 200) {
echo "Uploaded file: {$this->configParams['PDF_DOCUMENT_NAME']}\n";
} else {
echo "Failed to upload file.";
}
}
public function download_result() {
$response = $this->pdfApi->downloadFile($this->configParams['PDF_DOCUMENT_NAME']);
$filePath = $this->configParams['LOCAL_FOLDER'] . $this->configParams['LOCAL_RESULT_DOCUMENT_NAME'];
if ($response->getCode() === 200) {
file_put_contents($filePath, $response->getContents());
echo "Downloaded: $filePath\n";
} else {
echo "Failed to download file.";
}
}
public function deleteBookmark() {
$response = $this->pdfApi->deleteBookmark($this->configParams['PDF_DOCUMENT_NAME'], $this->configParams['BOOKMARK_PATH']);
if ($response->getCode() === 200) {
echo "Bookmark '{$this->configParams['DROP_BOOKMARK_PATH']} successfully deleted!";
}
}
function main() {
global $configParams;
try {
$pdfBookmarks = new PdfBookmarks($configParams);
$pdfBookmarks->uploadDocument();
$pdfBookmarks->deleteBookmark();
$pdfBookmarks->downloadResult();
} catch (\Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
}
在PDF中处理书签
从PDF中移除书签有助于保持文档准确性、优化性能、增强安全性,并确保正确格式化。特别是在共享、打印或存档文件之前,最终化文档时尤为重要。 使用Aspose.PDF Cloud PHP SDK从PDF文档中移除书签。
使用我们的PHP库,您可以:
- 在PDF文档中添加文本或图像格式的页眉和页脚。
- 向PDF文档中添加表格和印章(文本或图像)。
- 将多个PDF文档追加到现有文件。
- 处理PDF附件、注释和表单域。
- 对PDF文档进行加密或解密并设置密码。
- 从页面或整个PDF文档中删除所有印章和表格。
- 按ID从PDF文档中删除特定印章或表格。
- 替换PDF页面或整个文档中的单个或多个文本实例。
- 广泛支持将PDF文档转换为多种其他文件格式。
- 提取PDF文件的各种元素并优化PDF文档。
- 您可以尝试我们的免费应用在线测试功能。