Nglindhungi dokumen saka distribusi ora sah lan nambah watermark online. Kanggo nindakake iki, mung mbukak PDF, Word utawa format dokumen liyane lan tambahake teks utawa watermark gambar nggunakake Go. Banjur simpen PDF dokumen utawa Word sing ditandhani banyu ing format sing trep kayata DOC, DOCX, PDF, HTML, RTF, XPS lan liya-liyane. Sampeyan uga bisa mbusak tandha banyu saka dokumen supaya luwih gampang diproses kajaba nglanggar hak sapa wae.
Kanthi API Go iki, pangembang bisa nambah tandha banyu menyang PDF, Word, utawa dokumen liyane kanthi online. Sampeyan bisa nggawe tandha banyu nggunakake teks utawa gambar banjur lebokake tandha banyu kasebut menyang PDF dokumen utawa Word kanthi nyetel sudut overlay ing Go.
Cathetan: ora perlu nginstal aplikasi utawa perpustakaan pihak katelu. Mulane, solusi piranti lunak Go kita gampang banget digunakake.
SDK Go sing diwenehake uga mbantu mbusak tandha banyu. Contone, mbusak watermark ing Word tegese sampeyan bisa mbukak Word dokumen sing dipengini kanthi prangko teks utawa watermark gambar, mbusak tandha banyu iki saka dokumen nggunakake Go, banjur nyimpen file output ing format sing trep.
Kanggo ngevaluasi API Go kita, muat dokumen sing pengin ditambahake watermark lan watermark minangka gambar utawa teks. Banjur pilih format file ekspor sing trep - DOCX, PDF, MD, HTML, TXT, DOC, RTF, EPUB, XPS lan liya-liyane.
Gunakake conto ing ngisor iki kanggo ndeleng cara kerjane:
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Input1.docx")
requestImageStream, _ := os.Open("Input2.jpg")
requestWatermarkDataImage := models.CreateLocalFileReference(requestImageStream)
requestWatermarkData := models.WatermarkDataImage{
Image: &requestWatermarkDataImage
}
insertWatermarkOptions := map[string]interface{}{}
insertWatermarkRequest := &models.InsertWatermarkOnlineRequest{
Document: requestDocument,
WatermarkData: &requestWatermarkData,
Optionals: insertWatermarkOptions
}
insertWatermarkResult, _, _ = wordsApi.InsertWatermarkOnline(ctx, insertWatermarkRequest)
convertDocumentOptions := map[string]interface{}{}
convertRequest := &models.ConvertDocumentRequest{
Document: insertWatermarkResult.Document.Values[0],
Format: ToStringPointer("docx"),
Optionals: convertDocumentOptions
}
_, _ = wordsApi.ConvertDocument(ctx, convertRequest)
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Input.docx")
requestWatermarkData := models.WatermarkDataText{
Text: ToStringPointer("This is the watermark text"),
Layout: ToStringPointer("Diagonal")
}
insertWatermarkOptions := map[string]interface{}{}
insertWatermarkRequest := &models.InsertWatermarkOnlineRequest{
Document: requestDocument,
WatermarkData: &requestWatermarkData,
Optionals: insertWatermarkOptions
}
insertWatermarkResult, _, _ = wordsApi.InsertWatermarkOnline(ctx, insertWatermarkRequest)
convertDocumentOptions := map[string]interface{}{}
convertRequest := &models.ConvertDocumentRequest{
Document: insertWatermarkResult.Document.Values[0],
Format: ToStringPointer("docx"),
Optionals: convertDocumentOptions
}
_, _ = wordsApi.ConvertDocument(ctx, convertRequest)
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
requestDocument, _ := os.Open("Input.docx")
deleteWatermarkOnlineOptions := map[string]interface{}{}
deleteWatermarkOnline := &models.DeleteWatermarkOnlineRequest{
Document: requestDocument,
Optionals: deleteWatermarkOnlineOptions,
}
deletedWatermark = wordsApi.DeleteWatermarkOnline(ctx, deleteWatermarkOnline)
convertDocumentOptions := map[string]interface{}{}
convertDocument := &models.ConvertDocumentRequest{
Document: deletedWatermark.Document.Values[0],
Format: ToStringPointer("docx"),
Optionals: convertDocumentOptions,
}
_, _ = wordsApi.ConvertDocument(ctx, convertDocument)
Run go get -v github.com/aspose-words-cloud/aspose-words-cloud-go/2007/api kanggo nginstal Aspose.Words Cloud SDK for Go. Sampeyan bisa entuk akeh informasi migunani babagan cara instalasi liyane saka bagean "How to use SDK".
Klone Aspose.Words Cloud SDK for Go saka GitHub lan gunakake ing proyek sampeyan. Tututi Instructions iki supaya cepet entuk kredensial keamanan sing dibutuhake lan ngakses REST API kita.
Deleng Repository Documentation kanggo ndeleng rincian.