I am working on how to add empty paragraph after every end of the table

i want to add empty paragraph with certain style after the end of every table can anyone help me regarding this issue

@k.sukumar You can use CompositeNode.InsertAfter method to achieve what you need. For example see the following code:

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

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
foreach (Table t in tables)
{
    // Create a paragraph that should be added after the table.
    Paragraph p = new Paragraph(doc);
    // Set style.
    p.ParagraphFormat.StyleName = "Heading 1";

    // Insert the created paragraph after the table.
    t.ParentNode.InsertAfter(p, t);
}

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

@alexey.noskov thank you for the help…

iam facing an issue with tables and figures titles how to remove symbols form this titles help me to remove symbols

@k.sukumar Unfortunately, your last question is not quite clear. Could you please elaborate it in more details and attach your input and expected output documents? We will check the issue and provide you more information.

Hi @alexey.noskov,

how to apply diiferent styles to body of a paragraph excluding table and figures help me regarding this issue

i want to check whether table title and figure title has symbol style are not . Excluding all other paragraphs in word document

@k.sukumar You can use ParagraphFormat.StyleName property to get style name applied to the paragraph. But it is difficult to answer your question without your document and understanding of your requirements. To get timely and accurate response, please attach your input document and expected output. This will allow us to better understand your requirements and provide dedicated support.

Hi @alexey.noskov,
O-3.2.P.8.1-Stability-Summary-and-Conclusion.docx (41.5 KB)
please check this document in this we have table titles …for this titles only i have to check whether this titles are in symbol style are not…

Hi @alexey.noskov,

please consider above document only for that document i have to apply different styles for paragraph body excluding toc , tables and figures also if figures will exist .

@k.sukumar Thank you for additional information. Unfortunately, it is still not clear what you mean what say “symbol style”.
In general, you can use code like the following to get paragraphs that represents table caption and check the paragraphs properties, like style name:

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

// Replace colon in the paragraphs with SEQ field.
foreach (Field f in doc.Range.Fields)
{
    if (f.Type == FieldType.FieldSequence)
    {
        FieldSeq seq = (FieldSeq)f;
        if (seq.SequenceIdentifier == "Table")
        {
            // Get paragraph that represent table caption.
            Paragraph p = seq.Start.ParentParagraph;
            // Here you can check the caption paragraph properties.
            Console.WriteLine(p.ParagraphFormat.StyleName);
        }
    }
}

Hi @alexey.noskov,
help me regarding this issue also

@k.sukumar Could you be more specific? Unfortunately, your requirements are not clear enough. So please describe your requirements in more details and explain what you mean when say “symbol style”.

Hi @alexey.noskov,
i want to apply different styles to paragraph … if i have toc in document i need exclude that so that the style which iam applying need not change toc…same way i dont to apply table caption and figure captions …only i have to apply styles for paragraph …this is the issue am facing

please consider above document which i have attached yesterday

@k.sukumar Thank you for additional information, but unfortunately this does not make the things clearer.

The document you have attached does not have any TOC. Please clarify what TOC are you talking about.

You can apply style by setting style name or style identifier in ParagraphFormat. Please see our documentation to learn how to apply style to a paragraph.


It would be much easier if you provide you input document and expected output (you can create it manually in MS Word). And highlight what exactly you need to change in your document.

Hi @alexey.noskov,

i want to change tabs position from dots to none in which paragraph contains toc1 style. i have tried this code but not worked .
Hi,

Document doc = new Document("E:\\Output_original 2.3.P QOS - Small, Round Tab.doc");
DocumentBuilder db = new DocumentBuilder(doc);
Style toc1 = doc.Styles[StyleIdentifier.Toc1];
if (toc1 != null)
{
    toc1.ParagraphFormat.LeftIndent = Convert.ToDouble(1*72);
    toc1.ParagraphFormat.LineSpacing = Convert.ToDouble(2*12);
    toc1.ParagraphFormat.FirstLineIndent = Convert.ToDouble(2*12);
    toc1.ParagraphFormat.SpaceAfter = Convert.ToDouble(0.5*14);
    toc1.ParagraphFormat.TabStops.Add(200,TabAlignment.Left,TabLeader.None);
}

will you help me regarding this issue

O-3.2.S.7.3 Stability Data - Temperature Cycling Stability Data (Cryovessels) - Copy.docx (50.9 KB)

@k.sukumar You can use code like this to change tab leader in Toc1 style:

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

TabStopCollection tabStops = doc.Styles[StyleIdentifier.Toc1].ParagraphFormat.TabStops;
for(int i=0; i< tabStops.Count; i++)
    tabStops[i].Leader = TabLeader.None;

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

Thank you so much @alexey.noskov

1 Like

Hi @alexey.noskov,

i have attached the document in this for toc1 style i have change tab position to 0.76cm help me regarding this issue

O-3.2.S.7.3 Stability Data - Temperature Cycling Stability Data (Cryovessels) - Copy.docx (50.9 KB)