HTML
JPG
PDF
XML
DOCX
PDF
如何通过 Cloud Go SDK 裁剪 PDF
要裁剪 PDF 文档,我们将使用 Aspose.PDF Cloud Go SDK 此 Cloud SDK SDK 协助 Go 程序员使用 Go 编程语言通过 Aspose.PDF REST API 开发基于云的 PDF 创建、注释、编辑和转换应用程序。请使用包管理器控制台中的以下命令。
包管理器控制台命令
go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
通过 Go 裁剪 PDF 的步骤
Aspose.PDF Cloud 开发人员可以轻松地用几行代码加载和裁剪 PDF。
- 定义 cropDocumentPage 函数。
- 将 PDF 上传到云存储。
- 获取目标页面的信息。
- 将页面提取为图像。
- 将提取的图像插入到新的 PDF 中。
- 检查插入响应并下载结果。
使用 Cloud Go SDK 裁剪 PDF
package main
import (
"fmt"
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
)
func cropDocumentPage(pdf_api *asposepdfcloud.PdfApiService, document_name string, pageNumber int, llx int, lly int, width int, height int, outputDocument string, localFolder string, tempFolder string) {
uploadFile(pdf_api, document_name)
getPageInfo(pdf_api, document_name, pageNumber, tempFolder)
imageFile := extractPdfPage(pdf_api, document_name, pageNumber, int(CROP_PAGE_WIDTH), int(CROP_PAGE_HEIGHT), localFolder, tempFolder)
newPdf := createPdfDocument(pdf_api, outputDocument, width, height, tempFolder)
if newPdf.Code != 200 {
fmt.Println("cropPage(): Failed to create new PDF document!")
} else {
response := insertPageAsImage(pdf_api, outputDocument, imageFile, llx, lly, tempFolder)
if response.Code == 200 {
fmt.Println("cropPage(): Page successfully cropped.")
downloadFile(pdf_api, outputDocument, "cropped_")
} else {
fmt.Println("cropPage(): Can't crop pdf document page!")
}
}
}
使用我们的 Go SDK,您可以
- 以文本或图像格式添加 PDF 文档的页眉和页脚。
- 向 PDF 文档添加表格和文本或图像戳记。
- 将多个 PDF 文档追加到现有文件中。
- 处理 PDF 附件、注释和表单字段。
- 对 PDF 文档应用加密或解密并设置密码。
- 从页面或整个 PDF 文档中删除所有戳记和表格。
- 根据其 ID 从 PDF 文档中删除特定的戳记或表格。
- 替换 PDF 页面或整个文档中的单个或多个文本实例。
- 支持广泛将 PDF 文档转换为各种其他文件格式。
- 提取 PDF 文件的各种元素并优化 PDF 文档。
- 您可以尝试我们的 免费应用 来测试功能。