Hi I’m trying to apply some custom formatting on InsertHtml. I want to indent the text inserted using InsertHtml by half an inch to the left. The text will contain paragraphs, tables etc. I’m trying to use INodeChangingCallback for this but its not working for me. The intent that I apply has no effect. Here’s the code for my callback
public class HandleNodeChangingTextAlignment: INodeChangingCallback
{
void INodeChangingCallback.NodeInserted(NodeChangingArgs args)
{
if (args.Node.NodeType == NodeType.Paragraph)
{
((Paragraph)args.Node).ParagraphFormat.LeftIndent =200;
}
}
void INodeChangingCallback.NodeInserting(NodeChangingArgs args)
{
// Do Nothing
}
void INodeChangingCallback.NodeRemoved(NodeChangingArgs args)
{
// Do Nothing
}
void INodeChangingCallback.NodeRemoving(NodeChangingArgs args)
{
// Do Nothing
}
}
Here’s the code where I’m using this callback
string asposeWordsLic = @"D:\Aspose.Words.lic";
License lic = new License();
lic.SetLicense(asposeWordsLic);
Document doc = new Document(@"D:\test.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
doc.NodeChangingCallback = new HandleNodeChanging_FontChanger();
builder.InsertHtml("<p style='text-align: left;'>fsddfdsf</p><p>dsffsds</p><ol><li>fdsfdfd</li><li>fdsfdsdf</li><li>dfsdfffdsfdsf</li></ol><ul><li>fdsf</li></ul><p style='text-align: center;'> sfdfdsffdsdfsfd</p><ul><li>whatever<ul><li>nested</li></ul></li><li>non nested</li></ul><p>devendra</p>");
doc.Save("c://temp1//myfile.doc");
The generated myfile.doc has the html inserted but the left indent is not applied. It seems that the NodeInserted method is called when the paragraph is inserted but its content is inserted afterwards and somehow the left indentation gets ignored.
If there is a better way to customize the formatting done by InsertHtml method then let me know. I need to change the indentation of paragraphs and bullets.
Any help on this would be appreciated.