User`s guide

Create and Format Text
13-41
Create and Format Text
In this section...
“Create Text” on page 13-41
“Create Special Characters” on page 13-41
“Append HTML or XML Markup” on page 13-42
“Format Text” on page 13-42
Create Text
You can create text by appending a string to a document, paragraph, table entry, or list
item. The DOM append function converts the string to a Text object, appends it, and
returns the Text object. Use the Text object to format the text. You can also create a
text object directly and append it to a document. This example:
Creates the Text object t1 by appending the string 'Hello' to the document
Uses a Text constructor to create a Text object and append the text 'World' to the
document
import mlreportgen.dom.*
doc = Document('mydoc','html');
t1 = append(doc,'Hello');
append(doc, Text('World'));
close(doc);
rptview('mydoc','html');
Create Special Characters
You can define special characters, such as the British pound symbol, to
include in a report by creating an mlreportgen.dom.CharEntity object.
Specify a name of a character entity listed at http://en.wikipedia.org/wiki/
List_of_XML_and_HTML_character_entity_references. For example:
import mlreportgen.dom.*;
d = Document('test','html');