I am using a .docx file as a template and I am doing some processing to the document (insert text, etc) Before I save the document as a PDF.
Everything works great, but I have a problem to get and delete the next Paragraph after a specific table.
I can find and delete the table by using the following code:
How do I get and delete the paragraph that is directly below the table tToDelete?
I tought about useing the tToDelete.nextsibling, but that seem to return the next table instead of the next paragraph. I also tried to do a "foreach" loop of all blocks in the current section and delete the block that is directly after the table tToDelete, but that does not seem to work either since the blocks does not seem to be in order (top to bottom of the document).
Please note that I only want to process the document in memory and that I am therefore not using the actual RadRichTextBox Control.
Everything works great, but I have a problem to get and delete the next Paragraph after a specific table.
I can find and delete the table by using the following code:
//rdoc is the document, a .docx file used as a template.
//Search for the text "sometext".
DocumentTextSearch dts =
new
DocumentTextSearch(rdoc);
TextRange tr = dts.Find(
"sometext"
);
//Get the inline that the text is in.
Inline iCurrent = (Inline)tr.StartPosition.GetCurrentInline();
//Get the table to delete.
Table tToDelete = iCurrent.GetParentOfType<Table>();
//Delete the table.
sCurrent.Blocks.Remove(tToDelete);
How do I get and delete the paragraph that is directly below the table tToDelete?
I tought about useing the tToDelete.nextsibling, but that seem to return the next table instead of the next paragraph. I also tried to do a "foreach" loop of all blocks in the current section and delete the block that is directly after the table tToDelete, but that does not seem to work either since the blocks does not seem to be in order (top to bottom of the document).
Please note that I only want to process the document in memory and that I am therefore not using the actual RadRichTextBox Control.