GroupDocs.Assembly Cloud SDK for Go 은(는) 무거운 서드파티 라이브러리 없이도 모든 Go 애플리케이션에 강력한 문서 생성 기능을 삽입할 수 있게 합니다. 이 서비스는 완전 클라우드 기반이며 간단한 REST API 를 통해 통신합니다. 따라서 인터넷 연결과 API 자격 증명만 있으면 바로 문서 작성을 시작할 수 있습니다.
일반적인 워크플로는 세 가지 논리적 단계로 구성됩니다:
이 접근 방식은 계약서, 청구서, 선적 명세서, 영업 제안서 및 기타 모든 비즈니스 핵심 문서를 실시간으로 생성할 수 있게 합니다. 또한 개인화된 편지의 일괄 생성을 위한 Mail Merge, barcode 생성, HTML background 스타일링 및 email attachment 생성도 지원합니다. 모든 작업은 SSL/TLS 암호화와 API‑키 인증으로 보호되어 민감한 데이터가 클라우드를 떠나지 않도록 보장합니다.
무거운 작업이 클라우드에서 수행되기 때문에 SDK 는 Go 를 실행할 수 있는 모든 운영 체제(Windows macOS, Linux)에서 작동하며 표준 go get 설치 단계만 필요합니다. 추가 소프트웨어나 네이티브 Office 설치, 복잡한 파일 형식의 수동 처리 없이도 클라우드 서비스가 모든 복잡성을 추상화하므로 비즈니스 로직에 집중할 수 있습니다.
아래 스니펫은 템플릿을 업로드하고, 데이터 소스를 읽은 다음, Assembly API를 호출하여 Go를 사용해 문서를 생성하는 방법을 보여줍니다.
Steps
config.json에서 구성을 로드합니다.AssembleOptions를 설정합니다.AssembleDocument을 호출하고 조립된 파일을 받습니다.import (
"os"
"io/ioutil"
"github.com/groupdocs-assembly-cloud/groupdocs-assembly-cloud-go/api"
"github.com/groupdocs-assembly-cloud/groupdocs-assembly-cloud-go/api/models"
)
// 1. Initialise configuration
config, _ := models.NewConfiguration("config.json")
assemblyApi, ctx, _ := api.NewAPIClient(config)
// 2. Upload template
fileName := "Input1.docx"
requestFileContent, _ := os.Open(fileName)
uploadReq := &models.UploadFileRequest{
FileContent: requestFileContent,
Path: ToStringPointer(fileName),
}
_, _, _ = assemblyApi.UploadFile(ctx, uploadReq)
// 3. Read data source
dataFile := "Input2.docx" // can be XML or JSON
data, _ := ioutil.ReadFile(dataFile)
// 4. Prepare assemble options
templateInfo := api.TemplateFileInfo{FilePath: fileName}
assembleOptions := api.AssembleOptions{
TemplateFileInfo: &templateInfo,
SaveFormat: "docx",
ReportData: string(data),
}
// 5. Generate document
output, err := assemblyApi.AssemblyApi.AssembleDocument(ctx, assembleOptions)
if err != nil {
// handle error
}
// `output` contains the generated document