Easily open DOC documents with just a few lines of Go code. Our Go library will provide you with everything you need to access DOC document content programmatically.
The task of reading DOC documents is the task of reading hierarchical data structures within the DOM model. This implies knowing the format of each individual DOC data element, including all of its possible child elements and attributes.
Our Go library is a cloud-based solution that will allow you to open DOC files for reading and writing easily. This distributed approach gives you flexibility in software development using Go language, as all resource-intensive DOC document processing will take place on Aspose servers. All you need is to get private keys to access Cloud API in Go code.
You can iterate over all elements of a DOC document or you can search for specific elements in a DOM tree. We provide a wide range of Go functions both for working with the structure of the DOC file and with the data contained in the document nodes.
The following code example will help you quickly figure out how to load a DOC file using Go and perform some actions on it.
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:= "Input.doc"
requestFileContent, _ := os.Open(ReadFile(t, fileName))
uploadDocumentRequestOptions := map[string]interface{}{}
uploadDocumentRequest := &models.UploadFileRequest{
FileContent: requestFileContent,
Path: ToStringPointer(fileName),
Optionals: uploadDocumentRequestOptions,
}
_, _, _ = wordsApi.UploadFile(ctx, uploadDocumentRequest)
requestParagraph := models.ParagraphInsert{
Text: ToStringPointer("Reading and writing to the file in the cloud occurs automatically."),
}
insertParagraphRequestOptions := map[string]interface{}{}
insertParagraphRequest := &models.InsertParagraphRequest{
Name: ToStringPointer(fileName),
Paragraph: &requestParagraph,
Optionals: insertParagraphRequestOptions,
}
_, _, _ = wordsApi.InsertParagraph(ctx, insertParagraphRequest)
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 to install Aspose.Words Cloud SDK for Go. You can get a lot of useful information about other installation methods from the "How to use SDK" section.
Clone Aspose.Words Cloud SDK for Go source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.
Refer to the Repository Documentation to see the details.