Nambahake tandha banyu menyang PDF utawa mbusak tandha banyu sing sadurunge ditambahake nggunakake Go

Nganggo perpustakaan Go iki, cap PDF dokumen nganggo gambar utawa teks banyu utawa mbusak tandha banyu sing wis ditambahake ing sawetara langkah.

Tambah teks utawa gambar watermark menyang PDF dokumen nggunakake Go. Muat PDF dokumen lan lebokake tandha banyu sing dibutuhake. Banjur simpen asil ing format sing trep kayata DOCX, PDF, MD, HTML, TXT, DOC, RTF, EPUB, XPS lan liya-liyane, lan nuduhake dokumen sing diwenehi tandha banyu karo wong liya. Uga mbusak tandha banyu saka PDF dokumen yen tandha banyu sadurunge ditambahake menyang dokumen, lan alasan kanggo nambah ora relevan maneh.

Ndeleng potongan kode

PDF - nambah watermark ing Go

Kanthi API Go iki, pangembang bisa nambah tandha banyu menyang PDF online. Mung nggawe watermark nggunakake teks utawa gambar banjur lebokake watermark menyang PDF dokumen ing Go.

Cathetan: ora perlu nginstal aplikasi utawa perpustakaan pihak katelu. Mulane, solusi piranti lunak Go kita gampang banget digunakake.

Mbusak tandha banyu saka PDF - Go

SDK Go sing diwenehake uga mbiyantu mbusak tandha banyu saka PDF. Mbusak tandha banyu ing PDF tegese sampeyan bisa mbukak PDF dokumen sing dipengini kanthi prangko teks utawa gambar, mbusak tandha banyu iki saka PDF nggunakake Go, banjur simpen file output ing format sing trep - DOC, DOCX, PDF, JPEG, PNG, TIFF lan liya-liyane.

Nggarap watermark ing PDF

Kanggo ngevaluasi carane nambah utawa mbusak tandha banyu ing PDF nganggo API Go, muat PDF lan tandha banyu minangka gambar utawa teks. Banjur pilih format file ekspor sing trep - DOC, DOCX, PDF, HTML, RTF, XPS lan liya-liyane.

Gunakake conto ing ngisor iki kanggo ndeleng cara kerjane:

File kudu nambah watermarks
Kode roto
Unggah gambar sing pengin dilebokake
Pilih format target saka dhaptar
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.pdf")
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("pdf"),
    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.pdf")
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("pdf"),
    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.pdf")
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("pdf"),
    Optionals: convertDocumentOptions,
}
_, _ = wordsApi.ConvertDocument(ctx, convertDocument)
Kode roto
  
Nyalin kode Go menyang clipboard

Carane mbusak watermark ing PDF nggunakake Go

  1. Pasang Aspose.Words Cloud for Go
  2. Tambah referensi perpustakaan (ngimpor perpustakaan) menyang proyek Go sampeyan
  3. Konfigurasi API nggunakake tombol app
  4. Muat PDF dokumen sing pengin dibusak saka watermark
  5. Nggawe panjalukan kanggo mbusak watermark
  6. Simpen asil menyang format file sing trep

Pustaka Go kanggo nggunakake tandha banyu ing PDF

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.

Requirements Sistem

Deleng Repository Documentation kanggo ndeleng rincian.

Format file liyane sing didhukung

Sampeyan bisa nambah watermark menyang dokumen ing format liyane:

5%

Langganan kanggo Aspose Update Product

Entuk buletin saben wulan lan tawaran langsung dikirim menyang kothak layang.

© Aspose Pty Ltd 2001-2024. Kabeh hak dilindhungi undhang-undhang.