
MS Word 파일은 데이터 처리 및 정보 공유를 위한 인기 있는 오피스 파일 형식입니다. 여러 리소스가 조직에서 작업하고 매일 수많은 문서를 생성하며, 데이터 보관소의 경우 먼 지리적 위치에 있는 여러 팀이 생성한 문서를 병합해야 하는 요구 사항에 부딪힐 수 있습니다. 이 문서에서는 REST API를 사용하여 여러 Word 파일을 단일 결과 출력으로 결합하는 방법에 대한 단계를 설명합니다.
워드 프로세싱 REST API
Word 문서에는 다양한 형식이 있으며, 이러한 요구 사항을 충족하기 위해 Aspose.Words Cloud는 다양한 MS Word 및 OpenOffice 문서를 단일 파일에 결합하는 기능을 제공합니다. API를 사용하면 documentList 매개변수에 지정된 문서 또는 문서를 원래 리소스 파일에 추가할 수 있습니다. destFileName 매개변수가 지정되지 않으면 변경 사항이 원래 리소스 문서에 저장됩니다. 문서를 추가하는 동안 추가된 문서 또는 대상 문서 중에서 사용할 서식을 정의하는 옵션이 제공됩니다. 따라서 가능한 값은 KeepSourceFormatting 또는 UseDestinationStyles입니다.
cURL 명령을 사용하여 파일 병합
cURL 명령은 RESTful API를 사용하여 Word 문서 병합 작업을 수행하는 가장 쉬운 방법입니다.
curl -X PUT "https://api.aspose.cloud/v4.0/words/Working%20with%20Header_Footer%20Objects.docx/appendDocument?destFileName=MergedFile.doc" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{\"DocumentEntries\":[{\"Href\":\"Another sample file.docx\",\"ImportFormatMode\":\"KeepSourceFormatting\"}],\"ApplyBaseDocumentHeadersAndFootersToAppendingDocuments\":true}"
요청 URL
https://api.aspose.cloud/v4.0/words/Working%20with%20Header_Footer%20Objects.docx/appendDocument?destFileName=MergedFile.doc
C#를 사용하여 Word 파일 병합
C#.NET
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
public class AppendaDocument
{
public static void Run()
{
WordsApi wordsApi = new WordsApi(MyAppKey,MyAppSid);
try
{
string fileName = "Working with Header_Footer Objects.docx";
string documentToAppend = "Another sample file.docx";
// string folder = ""; // 파일이 저장소 루트에 존재합니다.
string destName = "Out_Merged.docx"; // // Changes will be made in the source document
var body = new Aspose.Words.Cloud.Sdk.Model.DocumentEntryList();
System.Collections.Generic.List<Aspose.Words.Cloud.Sdk.Model.DocumentEntry> docEntries = new System.Collections.Generic.List<Aspose.Words.Cloud.Sdk.Model.DocumentEntry>();
Aspose.Words.Cloud.Sdk.Model.DocumentEntry docEntry = new Aspose.Words.Cloud.Sdk.Model.DocumentEntry { Href = documentToAppend, ImportFormatMode = "KeepSourceFormatting" };
docEntries.Add(docEntry);
body.DocumentEntries = docEntries;
Aspose.Words.Cloud.Sdk.Model.Requests.AppendDocumentRequest request = new Aspose.Words.Cloud.Sdk.Model.Requests.AppendDocumentRequest(fileName, body, null, null,null,null, destName, null, null);
Aspose.Words.Cloud.Sdk.Model.DocumentResponse result = wordsApi.AppendDocument(request);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
추천 기사
또한, 자세한 내용을 알아보려면 다음 기사를 방문해 보세요.