通过Go SDK向PDF的特定页面添加文字戳记

使用Aspose.PDF Cloud Go SDK向PDF页面添加文字的API

Get Started

如何使用Cloud Go SDK向PDF页面添加文字戳记

为了向PDF文档添加文字戳记,我们将使用 Aspose.PDF Cloud Go SDK 这个Cloud SDK SDK帮助Go程序员使用Aspose.PDF REST API开发基于云的PDF创建、注释、编辑和转换应用程序。请在Package Manager Console中使用以下命令。

Package Manager Console命令


     
    go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
     
     

使用Go添加文字戳记到PDF的步骤

Aspose.PDF Cloud Go开发者可以轻松地向PDF文档添加文字戳记。开发者只需几行代码。

  1. 将PDF文件上传到云存储。
  2. 构建文字戳记。
  3. 添加文字戳记。
  4. 下载修改后的PDF。
 

此示例代码展示了使用PDF Cloud Go SDK向PDF文档添加文字戳记


    package main

    import (
        "fmt"

        asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
    )

    func AppendPageStampText(pdf_api *asposepdfcloud.PdfApiService, documentName string, pageNumber int32, outputDocument string, text_value string, remoteFolder string) {
        // Append text stamp to page of the PDF document.
        uploadFile(pdf_api, documentName)

        args := map[string]interface{}{
            "folder": remoteFolder,
        }

        textStamp := asposepdfcloud.TextStamp{
            Background:          true,
            HorizontalAlignment: asposepdfcloud.HorizontalAlignmentCenter,
            VerticalAlignment:   asposepdfcloud.VerticalAlignmentCenter,
            Opacity:             1,
            Rotate:              asposepdfcloud.RotationNone,
            RotateAngle:         30,
            Zoom:                1,
            TextAlignment:       asposepdfcloud.HorizontalAlignmentCenter,
            Value:               text_value,
            TextState:           &asposepdfcloud.TextState{FontSize: 14, FontStyle: asposepdfcloud.FontStylesBoldItalic, Font: "Arial", ForegroundColor: &asposepdfcloud.Color{A: 0xFF, R: 0xFF, G: 0x00, B: 0x00}},
        }

        _, httpResponse, err := pdf_api.PostPageTextStamps(documentName, pageNumber, []asposepdfcloud.TextStamp{textStamp}, args)
        if err != nil {
            fmt.Println(err.Error())
        } else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
            fmt.Println("appendStampText(): Failed to append text stamp to the document.")
        } else {
            fmt.Println("appendStampText(): text stamp '"+text_value+"' appended successfully on page", pageNumber, " to the document '"+documentName+"'.")
            downloadFile(pdf_api, documentName, outputDocument, "add_text_stamp_")
        }
    }
 

使用我们的Go SDK,您可以

  • 添加PDF文档的文本或图像格式的页眉和页脚。
  • 向PDF文档添加表格及文本或图像戳记。
  • 将多个PDF文档附加到现有文件。
  • 处理PDF附件、注释和表单字段。
  • 对PDF文档进行加密或解密并设置密码。
  • 从页面或整个PDF文档中删除所有戳记和表格。
  • 通过其ID从PDF文档中删除特定戳记或表格。
  • 替换PDF页面上的单个或多个文本实例或整个文档中的文本。
  • 广泛支持将PDF文档转换为多种其他文件格式。
  • 提取PDF文件的各种元素并优化PDF文档。
  • 您可以尝试我们的免费应用来测试功能。

  •