Kanthi solusi iki, Go pangembang bisa gampang nggawe dokumen ing PDF, DOC, DOCX, HTML, EPUB lan akeh format liyane kanthi mung sawetara baris kode. Solusi kita bakal menehi sampeyan kabeh sing dibutuhake kanggo nggawe file nggunakake Go SDK.
Kanthi REST API, pangembang Go bisa nggawe dokumen ing meh kabeh format. Kanggo nindakake iki, sampeyan kudu nindakake sawetara langkah nggunakake Go SDK kita:
Wiwit dokumen kosong mesthine ngemot siji paragraf, nalika sampeyan nggawe dokumen kanthi program, sampeyan bakal entuk struktur dhasar kasebut.
Elinga yen sampeyan bisa nambah konten menyang dokumen sing mentas digawe kanthi cepet. Mangkono, sampeyan bakal entuk ora mung dokumen kosong, nanging dokumen sing ngemot konten sing dibutuhake. Kanggo informasi luwih lengkap babagan cara ngowahi dokumen, deleng kaca 'Edit a Document'.
Kaya sing wis kasebut, Go SDK ngidini sampeyan nggawe dokumen kanthi program ing format apa wae sing didhukung. Contone, sampeyan bisa nggawe PDF, DOCX, DOC, RTF, ODT, EPUB, HTML lan file ing format liyane. Sampeyan bisa nyoba fungsi sing kuat lan ngevaluasi carane nggawe dokumen nggunakake conto Go ing ngisor iki:
import (
"os"
"github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)
config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)
fileName:= "Output.docx"
createDocumentRequestOptions := map[string]interface{}{"fileName": fileName,}
createDocumentRequest := &models.CreateDocumentRequest{
Optionals: createDocumentRequestOptions,
}
_, _, _ = wordsApi.CreateDocument(ctx, createDocumentRequest)
downloadDocumentRequestOptions := map[string]interface{}{}
downloadDocumentRequest := &models.DownloadFileRequest{
Path: ToStringPointer(fileName),
Optionals: downloadDocumentRequestOptions,
}
_, _ = wordsApi.DownloadFile(ctx, downloadDocumentRequest)
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.