Hello Team,
Hello
<?xml:namespace prefix = o />
Thanks for your inquiry. I think, as a workaround, in your case you can try using the technique as described in the following forum thread to change font color:
Best regards,
Hello,
Hi Dwarika,
Follow this link below to see the page Andrey is talking about.
It was just a small error at the end of the URL causing the wrong page to be loaded.
Thanks,
Hello,
Hello
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for additional information. In your case, you insert HTML in to the document and then using FontChanger you can easily change font color for whole document. All that you need is modifying FontChanger in order to change font color.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
string html = File.ReadAllText("yourHTML.html");
builder.InsertHtml(html);
// Create an object that inherits from the DocumentVisitor class.
FontChanger changer = new FontChanger(Color.Red);
//Get the model to accept a visitor.
// The model will iterate through itself by calling the corresponding methods
// on the visitor object (this is called visiting).
doc.Accept(changer);
//Save output document
doc.Save("out.doc");
Best regards,
Hello,
Test Test |
Hello
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. You can use InsertHtml method to insert an HTML fragment or whole HTML document. You should use FontChanger after inserting HTML into the document. It does not matter which way of inserting HTML you are using. You can read HTML from a file or inset as a string.
Best regards,
Hello,
Hello,
Hi Dwarika,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. Yes, you need to accept FontChanger after inserting HTML. Please take a look on the code example Andrey provided.
Best regards.
Hello,
I could not find the Class FontChanger in Aspose.Words.
Could you please elaborate more on DocumentVisitor and FontChanger Class?
Also if possible send us the code sample for same.
Regards,
Dwarika
Hello
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. FontChanger class is attached.
The code example you can found here:
Best regards,
Hello,
Thanks for the code file, i have still one more doubt as follows,
If we use this font changer, this will chnage the colour of the entire document? or the selected string ?
Regards,
Dwarila
Hi there,
Thanks for your inquiry.
Yes, the visitor will change the font of all content visited during the enumeration. In this case, since the sample above is run on the document (doc.Accept) this will visit all nodes in the document and change the font for all appropriate nodes.
You can try running the class on just the particlar node or nodes that are inserted by the InsertHtml method but this may be hard if there are many nodes inserted. Instead you may want to take a look at the method used in this post here which may be easier.
Thanks,