1

I am Trying to Insert HTML Text Inside Apache Open Office .odt File

I try Statement with Bold as show Below but it is not Working.

Is There I am missing Something ?

XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
        XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();

  XComponentLoader oDesk = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
    string url = @"private:factory/swriter";
PropertyValue[] propVals = new PropertyValue[0];

XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
string docText = "<b>This will</b> be my first paragraph.\n\r";
docText += "This will be my second paragraph.\n\r";
((XTextDocument)oDoc).getText().setString(docText);
string fileName = @"C:\test.odt";
fileName = "file:///" + fileName.Replace(@"\", "/");
((XStorable)oDoc).storeAsURL(fileName, propVals);
((XComponent)oDoc).dispose();
oDoc = null;

Output:

enter image description here

Dgan
  • 10,077
  • 1
  • 29
  • 51

1 Answers1

0

As answered already in the other question - you have to use character properties to get bold (or otherwise attributed) text

Community
  • 1
  • 1
ngulam
  • 995
  • 1
  • 6
  • 11
  • i Already build Long HTML for `Exporting MS Word ` I want to find solution or is there is any way i can inject HTML directly inside these `.odt` files – Dgan Jan 05 '15 at 19:10