INodeChangingCallbackNodeRemoved Method |
Namespace: Aspose.Words
public void FontChangeViaCallback() { // Create a blank document object Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set up and pass the object which implements the handler methods doc.NodeChangingCallback = new HandleNodeChangingFontChanger(); // Insert sample HTML content builder.InsertHtml("<p>Hello World</p>"); doc.Save(ArtifactsDir + "Document.FontChangeViaCallback.doc"); // Check that the inserted content has the correct formatting Run run = (Run) doc.GetChild(NodeType.Run, 0, true); Assert.AreEqual(24.0, run.Font.Size); Assert.AreEqual("Arial", run.Font.Name); } public class HandleNodeChangingFontChanger : INodeChangingCallback { // Implement the NodeInserted handler to set default font settings for every Run node inserted into the Document void INodeChangingCallback.NodeInserted(NodeChangingArgs args) { // Change the font of inserted text contained in the Run nodes if (args.Node.NodeType == NodeType.Run) { Aspose.Words.Font font = ((Run) args.Node).Font; font.Size = 24; font.Name = "Arial"; } } void INodeChangingCallback.NodeInserting(NodeChangingArgs args) { // Do Nothing } void INodeChangingCallback.NodeRemoved(NodeChangingArgs args) { // Do Nothing } void INodeChangingCallback.NodeRemoving(NodeChangingArgs args) { // Do Nothing } }