Support iterating Word document with mixed types(paragraph and table type)

Support iterating Word document with mixed types(paragraph and table type)
1

Upvotes

Upvote

 Dec 12 2023
0 Comments 
New

Hi,

I have a word document with following content

Screenshot from 2023-12-13 10-28-45.png

How can I iterate document content in order regardless of types? In above case, what I want to get is "paragraph1", "paragraph2", "table", "paragraph3", "paragraph4" in order.

 

Right now I can only get "paragraphs" in order or "tables" in order(via `context.document.body.paragraphs` or `context.document.body.tables`), but not mix of them at the same time. I know that `context.document.body.paragraphs` also returns the nested paragraphs in tables, but I not only want paragraphs inside the table, but also other information of the table.

Per my imagination, there would be a `context.document.body.blocks` API, and each block has a type field telling your it is a paragraph block or a table block. Right now there seems no such a way to get mixed types of content in order? If there is a workaround, please let me know how.

 

Thanks!