WordsAPI splitting document to wrong number of pages

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 КБ)

Please share input document for analysis.

test_inbal3.docx (325,5 КБ)

This behavior I saw not just for this document, you can generate some “Lorem impum” documents that have more than 30 pages and will see such a problem

Thanks for sharing document, after analysis is complete I will share the result with you

I opened this document in MS Word, and it shows me that document has 100 pages, not 95
image.png (31.3 KB)
That’s why you get more split pages than you expect.

It’s strange but ok. When we join these pages back

        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',
          }),
        );

I have the problem that texts of pages aren’t joined and I have big space between them. Could I change some flags to fix it?
Screenshot 2024-10-24 at 11.42.51.png (113,9 КБ)

@LegalUp
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSCLOUD-2865

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

This behavior is happening because all pages have their page setup to be set. That’s why we created a separate page for every appended document. We will introduce a new parameter to append all pages into one section forcibly.

@yaroslaw.ekimov do you have an estimate of when it could be available in API?

If the implementation passes all internal checks quickly, the functionality will be available in API version 24.11; otherwise, it will be included in version 24.12.

The issues you have found earlier (filed as WORDSCLOUD-2865) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John