HTML
JPG
PDF
XML
DOCX
PDF
Cloud Go SDK を使用して PDF ドキュメントのテキスト注釈を置換する方法
PDF ドキュメントの注釈を置換するために、我々は Aspose.PDF Cloud Go SDK この Cloud SDK は、Go プログラマーが Aspose.PDF REST API を介して Go プログラミング言語を使用してクラウドベースの PDF クリエーター、注釈付け、エディター、およびコンバーターアプリを開発するのを支援します。パッケージ マネージャー コンソールから次のコマンドを使用します。
パッケージ マネージャー コンソール コマンド
go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
Go を使用して注釈を置換する手順
Aspose.PDF Cloud Go 開発者は、PDF ドキュメントの注釈を簡単に置換できます。開発者は数行のコードが必要なだけです。
- ファイルをクラウドストレージにアップロードします。
- getAnnotation はクラウドに保存されている PDF から ID によってテキスト注釈を取得します。
- ModifyAnnotation はその注釈の内容とアイコンを更新します。
- 修正後、更新された PDF はローカルにダウンロードされます。
このサンプルコードは、PDF Cloud Go SDK を使用して PDF ドキュメントのテキスト注釈を置換する方法を示しています
package main
import (
"fmt"
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
)
func getAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, annotation_id string, remote_folder string) *asposepdfcloud.TextAnnotation {
// Get annotation by Id in the PDF document.
args := map[string]interface{}{
"folder": remote_folder,
}
result, httpResponse, err := pdf_api.GetTextAnnotation(document_name, annotation_id, args)
if err != nil {
fmt.Println(err.Error())
return nil
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
fmt.Println("getAnnotation(): Failed to get annotation in the document.")
return nil
} else {
fmt.Println("getAnnotation(): nnotation '" + annotation_id + "' successfully found '" + result.Annotation.Contents + "' in the document '" + document_name + "'.")
return result.Annotation
}
}
func ModifyAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, output_document string, annotation_id string, remote_folder string) {
// Change annotation by Id in the PDF document.
UploadFile(pdf_api, document_name)
args := map[string]interface{}{
"folder": remote_folder,
}
annotation := getAnnotation(pdf_api, document_name, annotation_id, remote_folder)
annotation.Contents = REPLACED_CONTENT
annotation.Icon = asposepdfcloud.TextIconStar
_, httpResponse, err := pdf_api.PutTextAnnotation(document_name, annotation_id, *annotation, args)
if err != nil {
fmt.Println(err.Error())
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
fmt.Println("ModifyAnnotation(): Failed to modify annotation in the document.")
} else {
fmt.Println("ModifyAnnotation(): annotation '" + annotation.Id + "' successfully modified in the document '" + document_name + "'.")
DownloadFile(pdf_api, document_name, output_document, "replaced_annotatiom_")
}
}
Go SDK でできること
- PDF ドキュメントのヘッダーとフッターをテキストまたは画像形式で追加します。
- テーブルやテキスト、または画像スタンプを PDF ドキュメントに追加します。
- 複数の PDF ドキュメントを既存のファイルに追加します。
- PDF の添付ファイル、注釈、およびフォームフィールドを操作します。
- PDF ドキュメントに暗号化や復号化を適用し、パスワードを設定します。
- ページまたは PDF ドキュメント全体からすべてのスタンプとテーブルを削除します。
- ID によって PDF ドキュメントから特定のスタンプまたはテーブルを削除します。
- PDF ページまたはドキュメント全体から単一または複数のテキストインスタンスを置換します。
- PDF ドキュメントをさまざまな他のファイル形式に変換するための広範なサポート。
- PDF ファイルのさまざまな要素を抽出し、PDF ドキュメントを最適化します。
- PDF ファイル内の注釈をオンラインで置換し、機能をテストするための 無料アプリ を試すことができます。