Skip to main content

Метод document:merge

Метод Document:merge сравнивает текущий документ с другим документом, который передается в параметре типа DocumentAPI.Document.

Метод возвращает объект DocumentAPI.Document, содержащий результат сравнения в виде отслеживаемых изменений.

Пример​


function MergeSample.mergeDocuments(context)
context.doWithApplication(function(application)
local docSettings = DocumentAPI.DocumentSettings()
docSettings.documentType = DocumentAPI.DocumentType_Text
local loadSettings = DocumentAPI.LoadDocumentSettings()
loadSettings.commonDocumentSettings = docSettings

local firstDoc = application:loadDocument("c:\\Tmp\\Sample1.docx", loadSettings)
local secondDoc = application:loadDocument("c:\\Tmp\\Sample2.docx", loadSettings)

local mergedDoc = firstDoc:merge(secondDoc)
mergedDoc:saveAs( "c:\\Tmp\\Sample3.docx")
end)
end

Результат выполнения данного примера (сравнение двух документов, содержащих "1111" и "2222") приведен на рисунке.