We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bold style is lost when text style is changed from paragraph style to caption style

I am changing style of all table captions in document which are in Paragraph style to Caption style. Both styles have bold status for text. But when caption style is applied, text is loosing bold. When we see style name of changed text in styles list, its style is shown as Caption+Not Bold.
In sample file.
Table 3. Specifications Chlorobutyl Rubber Stopper
is becoming to
Table 3. Specifications Chlorobutyl Rubber Stopper

    public static void CaptionStyle(String FileIn, String FileOut)
    {
        string sourcepath = FileIn;
        Document doc = new Document(sourcepath);
        Style Captionstyles = null;
        StyleCollection stylist = doc.Styles;
        Captionstyles = stylist.Where(x => x.StyleIdentifier == StyleIdentifier.Caption).FirstOrDefault();
        List<Node> paragraphs = doc.GetChildNodes(NodeType.Paragraph, true).Where(x => ((Paragraph)x).ParagraphFormat.StyleName.ToUpper() == "PARAGRAPH").ToList();

        foreach (Paragraph paragraph in paragraphs)
        {
            if ((paragraph.GetText().ToUpper().TrimStart().StartsWith("TABLE" + ControlChar.SpaceChar)))
            {
                  paragraph.ParagraphFormat.Style = Captionstyles;
            }
        }
        doc.Save(FileOut);
    }

Please find above code and input/ouput documents in zip formatcaptions.zip (48.7 KB)

@crshekharam,
We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET - 23317. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.