HTML
JPG
PDF
XML
DOCX
PDF
如何使用 Cloud Go SDK 向 PDF 页面添加图像印章
为了向 PDF 文档添加图像印章,我们将使用 Aspose.PDF Cloud Go SDK 这个 Cloud SDK SDK 帮助 Go 程序员使用 Aspose.PDF REST API 开发基于云的 PDF 创建、注释、编辑和转换应用程序。请使用以下命令从包管理器控制台运行。
包管理器控制台命令
go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
使用 Go 添加图像印章到 PDF 的步骤
Aspose.PDF Cloud Go 开发人员可以轻松地将图像印章附加到 PDF 文档。开发人员只需几行代码。
- 将 PDF 和图像上传到云存储。
- 创建具有指定大小和对齐方式的图像印章。
- 将图像印章添加到所需的 PDF 页面。
- 下载已加印章的 PDF。
此示例代码显示如何使用 PDF Cloud Go SDK 向 PDF 文档添加图像印章
package main
import (
"fmt"
"path"
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
)
func AppendPageStampImage(pdf_api *asposepdfcloud.PdfApiService, documentName string, outputDocument string, imageFileName string, pageNumber int32, width float64, height float64, remoteFolder string) {
// Append image stamp to page of the PDF document.
uploadFile(pdf_api, documentName)
uploadFile(pdf_api, imageFileName)
args := map[string]interface{}{
"folder": remoteFolder,
}
stamp := asposepdfcloud.ImageStamp{
Background: true,
HorizontalAlignment: asposepdfcloud.HorizontalAlignmentCenter,
VerticalAlignment: asposepdfcloud.VerticalAlignmentCenter,
Opacity: 1,
Rotate: asposepdfcloud.RotationNone,
RotateAngle: 45,
Width: width,
Height: height,
Zoom: 1,
FileName: path.Join(remoteFolder, imageFileName),
}
_, httpResponse, err := pdf_api.PostPageImageStamps(documentName, pageNumber, []asposepdfcloud.ImageStamp{stamp}, args)
if err != nil {
fmt.Println(err.Error())
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
fmt.Println("appendStampImage()): Failed to append image stamp to the document.")
} else {
fmt.Println("appendStampImage(): image stamp '"+imageFileName+"' appended successfully pn page", pageNumber, " to the document '"+documentName+"'.")
downloadFile(pdf_api, documentName, outputDocument, "add_image_stamp_")
}
}
使用我们的 Go SDK,您可以
- 以文本或图像格式添加 PDF 文档的页眉和页脚。
- 向 PDF 文档添加表格和文本或图像印章。
- 将多个 PDF 文档附加到现有文件。
- 处理 PDF 附件、注释和表单字段。
- 对 PDF 文档进行加密或解密并设置密码。
- 从页面或整个 PDF 文档中删除所有印章和表格。
- 通过 ID 从 PDF 文档中删除特定印章或表格。
- 替换 PDF 页面或整个文档中的单个或多个文本实例。
- 大力支持将 PDF 文档转换为各种其他文件格式。
- 提取 PDF 文件的各种元素并优化 PDF 文档。
- 您可以尝试我们的免费应用来测试功能。