How to remove an empty paragraph after table title

@alexey.noskov How to remove “\r” from table titles. tables titles can take by using seq number .

@alexey.noskov How to remove “\r” from table titles. tables titles can take by using seq number
,it is reading as bookmark start, am unable to replace it as empty string plz help me out.

@srinu12 \r is usually a paragraph break, so if you need to remove it, you should remove whole paragraph. Could you please attach your input and expected output document along with code you are using to remove the table title? We will check and provide you more information.

am trying to replace that paragraph break with empty ,is it possible to replace that paragraph break.

@srinu12 If you are using Range.Replace method, you can use a special &p metacharacter to match paragraph break. For example the following code removes all paragraph breaks in your document:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Range.Replace("&p", "");
doc.Save(@"C:\Temp\out.docx");

in.docx (12.1 KB) out.docx (9.5 KB)

But if you need to remove whole paragraph that represent the title, simply use Paragraph.Remove method:

Document doc = new Document(@"C:\Temp\in.docx");
// Get the paragraph you need to remove.
// For demonstration purposes the second paragraph is removed.
Paragraph para = doc.FirstSection.Body.Paragraphs[1];
para.Remove();
doc.Save(@"C:\Temp\out.docx");

@alexey.noskov by using above code removing paragraph breaks but its also removing its caption style.and other styles pls look in to this.

@srinu12 This is expected behavior, since style is applied to the paragraph. When you remove paragraph break, you actually remove the paragraph and copies its content to the neighbor paragraph, which might have different style applied.
Could you please attach your input and expected output documents here for our reference, we will check them and provide you more information,

@alexey.noskov attachments added for table 1 title in document test document have paragraph break i want to remove that break , and expected output also attached012 Document test.docx (66.9 KB)
JOB2012_Output_012 Document test.docx (65.5 KB)

@srinu12 In your case you simply need to remove an empty paragraph after the table title. Please see the following code:

Document doc = new Document(@"C:\Temp\in.docx");

List<Field> tableTitleSeqFields = doc.Range.Fields
    .Where(f => (f.Type == FieldType.FieldSequence) && (((FieldSeq)f).SequenceIdentifier == "Table")).ToList();

foreach (Field f in tableTitleSeqFields)
{
    // Get parent paragraph.
    Paragraph title = f.Start.GetAncestor(NodeType.Paragraph) as Paragraph;

    if (title != null)
    {
        // Remove next paragraph after title if it is empty.
        Paragraph nextPara = title.NextSibling as Paragraph;
        if (nextPara != null && !nextPara.HasChildNodes)
            nextPara.Remove();
    }
}

doc.Save(@"C:\Temp\out.docx");

@alexey.noskov i need to remove paragraph break only not an empty paragraph.

@srinu12 Paragraph break produces a new paragraph so removing paragraph break actually removes the paragraph. The provided code produces the output that looks exactly as your expected output.