PNG
JPG
BMP
TIFF
PDF
如何通过云 PHP SDK 删除 PDF 中的表格
要从 PDF 中删除表格,我们将使用 Aspose.PDF Cloud PHP SDK 此云 SDK 协助 PHP 程序员开发基于云的 PDF 创建、注释、编辑和转换应用程序,使用 PHP 编程语言通过 Aspose.PDF REST API。只需在 Aspose for Cloud 创建一个帐户并获取您的应用程序信息。一旦您拥有 App SID 和密钥,您就可以开始使用 Aspose.PDF Cloud PHP SDK。
包管理器控制台命令
composer install
通过云 PHP 删除 PDF 中表格的步骤
Aspose.PDF Cloud 开发人员可以轻松地在几行代码中加载和删除 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() {
$pdfFilePath = $this->configParams['LOCAL_FOLDER'] . $this->configParams['PDF_DOCUMENT_NAME'];
$pdfFileData = file_get_contents($pdfFilePath);
$this->pdfApi->uploadFile($this->configParams['PDF_DOCUMENT_NAME'], $pdfFileData);
}
public function downloadResult() {
$changedPdfData = $this->pdfApi->downloadFile($this->configParams['PDF_DOCUMENT_NAME']);
$filePath = $this->configParams['LOCAL_FOLDER'] . $this->configParams['LOCAL_RESULT_DOCUMENT_NAME'];
file_put_contents($filePath, $changedPdfData);
echo "Downloaded: " . $filePath . "\n";
}
public function getAllTablesInfo () {
$resultTables = $this->pdfApi->getDocumentTables($this->configParams['PDF_DOCUMENT_NAME']);
if ($resultTables->getCode() == 200) {
echo "All tables:";
var_dump($resultTables->getTables()->getList());
}
else
echo "Unexpected error : can't get tables !!!\n";
}
public function deleteTable () {
$resultTables = $this->pdfApi->deleteTable($this->configParams['PDF_DOCUMENT_NAME'], $this->configParams['TABLE_ID']);
if ($resultTables->getCode() == 200)
echo "Table #{$this->configParams['TABLE_ID']} deleted!\n";
else
echo "Unexpected error : can't delete table !\n";
}
public function deleteTablesOnPage () {
$resultTables = $this->pdfApi->deletePageTables($this->configParams['PDF_DOCUMENT_NAME'], $this->configParams['PAGE_NUMBER']);
if ($resultTables->getCode() == 200)
echo "Tables on page #{$this->configParams['PAGE_NUMBER']} deleted!\n";
else
echo "Unexpected error : can't delete tables!!!\n";
}
function main() {
global $configParams;
try {
$pdfTables = new PdfTables($configParams);
$pdfTables->uploadDocument();
$pdfTables->getAllTablesInfo();
$pdfTables->deleteTable();
$pdfTables->getAllTablesInfo();
$pdfTables->deleteTablesOnPage();
$pdfTables->getAllTablesInfo();
$pdfTables->downloadResult();
} catch (\Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
}
在 PDF 中处理表格
表格提供了一种系统呈现数据的格式,使读者更容易理解和分析信息。它们还增强了文档的视觉吸引力,增加了专业性和组织性。在处理数字或比较数据时,表格通过将相关信息分组在易于阅读的格式中提高了清晰度。此外,表格可以结合实时或动态生成的内容,如来自数据库或分析仪表板的数据。 使用 Aspose.PDF Cloud PHP SDK 从 PDF 文档中移除表格。
使用我们的 PHP 库,您可以:
- 以文本或图像格式添加 PDF 文档的页眉和页脚。
- 向 PDF 文档添加表格和印章(文字或图片)。
- 将多个 PDF 文档附加到现有文件。
- 处理 PDF 附件、注释和表单字段。
- 对 PDF 文档应用加密或解密并设置密码。
- 从页面或整个 PDF 文档中删除所有印章和表格。
- 通过其 ID 从 PDF 文档中删除特定的印章或表格。
- 替换 PDF 页面或整个文档中的单个或多个文本实例。
- 提供广泛支持,将 PDF 文档转换为多种其他文件格式。
- 提取 PDF 文件的各种元素并优化 PDF 文档。
- 您可以尝试我们的 免费应用程序 在线测试功能。