We are using WordAPI to split and join documents. We prepared logic that split documents into empty pages and then joined these pages to different documents. The problem is that API split documents by pages in the wrong way. For example: if the document has 95 pages, API returns the result with splitting to 99 pages. (See screenshots)
After we start to join these pages API not join text correctly and leave big spaces because it splits in the wrong way.
Could you help us with solving this issue? Two options are acceptable for us:
- fix splitting to see correct number of pages and after we will not have issues with joining OR
- fix or say how to join pages without spaces between pages (to join content of pages without page break)
Split document code:
const splitRequestResult = await wordsApi.splitDocumentOnline(
new SplitDocumentOnlineRequest({
document: bufferToStream(requestDocumentBuffer),
format: 'txt',
destFileName: splitRequestTxtFileName,
}),
);
Join pages code:
const firstPage = pagesArr.shift();
const documentEntries = pagesArr.map(
(page) =>
new DocumentEntry({
fileReference: FileReference.fromLocalFileContent(
bufferToStream(page),
),
importFormatMode: 'UseDestinationStyles', // 'KeepSourceFormatting',
}),
);
const res = await wordsApi.appendDocumentOnline(
new AppendDocumentOnlineRequest({
document: bufferToStream(Buffer.from(firstPage)),
documentList: new DocumentEntryList({
documentEntries: documentEntries,
}),
destFileName: 'doc',
format: 'docx',
}),
);
1.png (153,1 КБ)