In short, I'm trying to insert a table between existing paragraphs.
Our users need to upload a docx that contains tokens/placeholders which will then be replaced by text or sometimes a table. Finding the tokens is easy, and replacing them with text too. Adding a table on a specific location is another thing.
Suppose the document structure is as follows:
Document
-Section
--Body
---Paragraph 1
---Paragraph 2
---Paragraph 3
I'm starting with
- Code: Select all
TextSelection[] textSelection = document.FindAllPattern(regexPattern);
I can then call GetAncestor(..) on a TextRange of that selection to get its Paragraph, its Body, its Section, etc
So how do I insert a table between Paragraph 1 and Paragraph 2?
Section and Body both have an AddTable(..) method, but this will add the Table after all existing paragraphs.
Do I need to create the body from scratch and add everything in order?
Thank you