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

Free Support Forum - aspose.com

Clone method doesn't work properly

Hi Aspose,

Seems that Clone() method doesn’t clone the font.

Example:
original font name = Arial
clone font name = Times New Roman

Test file:ex.zip (11.2 KB)

Source code:

        Document doc = new Document("C:\\ex.doc");

        Body body = doc.FirstSection.Body;

        Node[] nodes = body.ChildNodes.ToArray();
        foreach (var node in nodes)
        {
            foreach(var n in ((CompositeNode)node).ChildNodes.ToArray()) {
                if(n.NodeType == NodeType.Run)
                {
                    Run run = (Run)n;
                    Console.WriteLine(n.GetText());
                    Console.WriteLine("original font name = " + run.Font.Name);
                    Run cloneRun = (Run)run.Clone(true);
                    Console.WriteLine("clone font name = " + cloneRun.Font.Name);
                }
            }
        }
        Console.ReadLine();

Thanks.

@spectr100,

We are working over your query and will get back to you soon.

@spectr100,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16668. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

@spectr100,

Regarding WORDSNET-16668, we have completed the work on your issue and have come to a conclusion that this issue is actually not a bug. So, we have closed this issue as ‘Not a Bug’. Please see the following details:

Arial font name is specified in Normal paragraph style and Run node itself has no direct formatting. Cloned Run node has no parent until it is inserted somewhere so it returns only the directly applied formatting. Since there is no direct formatting at all, the default value “Times New Roman” is returned.