Ok, thanks for the help Robin. 
But now I have another problem. When I press Enter key in my document, on export it gives me <p><span><span/><p/> .
I read the same issue in these forums, but still couldn't find a suitable way to implement the same. I tried overriding the keyDownHandler, and tried some way to prevent the extra <p><span><span/><p/> values, but nothing helped.Also I was unable to prevent it from going to its parent. I used event.preventDefault() but still it crearted a new paragraph. So how to stop it from calling the parent. The max I could get from the code was:
<p><span>Some text.</span></p>
<p><span><br/><span/><span>The text after I pressed Enter key<span/><p/>.
I actually want is that instead of creating a new paragraph and a span, I get a <br /> element. So that when I press the Enter key, I get <br/> attached to the text on export.
So can you please guide me on how can I handle this issue.
Thanks.
Here are some ideas, I'm not sure what will work best for you - it depends on the details of what you want.
If all you want is for the enter key to insert <br/>, you can just tell TLF not to handle the enter key, and then you can handle it yourself by inserting a break.
To turn off the automatic handling of the enter key, you turn it off in the Configuration object before you create the TextFlow. There is a single default Configuration used for creating TextFlows when the Configuration is not specified, or it can be overridden when you construct each TextFlow. So if you want to handle the enter key for ALL TextFlows in the application, change the TextFlow.defaultConfiguration.manageEnterKey=false. Otherwise create a new Configuration instance, set manageEnterKey=false, and use that instance when creating TextFlows.
Then create a class that inherits from EditManager, and overrides the keyDownHandler function. In the case where the event.charCode is Keyboard.ENTER, call editManager.insert('\u2028'). This will end the line, but extend the paragraph, and is identical to a <br/>.
Note that growing a huge paragraph (e.g., multiple page's worth of printed text) is likely to cause performance degradation.
Hope this helps,
- robin