User`s guide

Append HTML Content to DOM Reports
13-93
Append HTML Content to DOM Reports
In this section...
“Use an addHTML Method” on page 13-93
“Append an HTML Object” on page 13-94
“Address Errors” on page 13-94
You can append strings of HTML content to a DOM document or document part using
either of these approaches:
Use the addHTML method with a Document or DocumentPart object.
Create and append an HTML object.
If the HTML content that you append does not meet DOM requirements, the DOM API
generates error messages. You can use an HTML cleanup program such as HTML Tidy
on a file containing the source HTML content. HTML Tidy fixes many issues and also
identifies issues you need to address manually. After you clean up the source HTML
content, append it to a DOM report.
Use an addHTML Method
You can use the addHTML method with an mlreportgen.dom.Document or
mlreportgen.dom.DocumentPart object to add a string of HTML content to a DOM
report.
For example, you can use addHTML to create an HTML object that you append to a DOM
report that produces Word output.
import mlreportgen.dom.*;
rpt = Document('HTMLToWordReport','docx');
htmlObj = addHTML(rpt,...
'<p><b>Hello</b> <i style="color:green">World</i></p>');
close(rpt);
rptview(rpt.OutputPath);