Convert two column word document to single column document

Hi everyone,

I am trying to convert multi-column word document to single column word document. After converting I would like to clear all the formatting of the original and apply new format such as styling and such.
I have mapped the flow somehow like this;

  1. Clean all the existing formatting
  2. Run through each paragraph to find column break and delete it
  3. manipulate page setup for each paragraph parent section

This sounds good in theory but when I implemented it the result wasn’t what I expected.
So, if I could get a guidance or idea to move forward it would be much appreciated.
Thank you

Hi Sunil,

Thanks for your inquiry. Please share your input and expected output Word documents. We will then provide you more information about your query along with code.

Hi Tahir,
I have uploaded test documents. multiColDocInputTest.docx is the one for input while the other is expected one.

Thank you

Hi Sunil,

Thanks for sharing the documents. Please use following code example to achieve the desired output. Hope this helps you.

Document doc = new Document(MyDir + "multiColDocInputTest.docx");
doc.FirstSection.PageSetup.LeftMargin = 72;
doc.FirstSection.PageSetup.RightMargin = 72;
foreach (Run run in doc.GetChildNodes(NodeType.Run, true).Cast<Run>().Where(run => run.Text == ControlChar.ColumnBreak))
    run.Text = "";
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    para.ParagraphFormat.LeftIndent = 0;
doc.Save(MyDir + "Out.docx");
private static void RemoveSectionBreaks(Document doc)
    // Loop through all sections starting from the section that precedes the last one 
    // and moving to the first section.
    for (int i = doc.Sections.Count - 2; i >= 0; i--)
        // Copy the content of the current section to the beginning of the last section.
        // Remove the copied section.

Hi Tahir,

Thank you, for the update.
I will test the code and provide you the feedback.

With Regards