To add custom styles to a PDF template you can use the following workflow:
1. <https://www.mathworks.com/help/rptgen/ug/create-an-html-template.html Create a PDF template>, for example:
>> mlreportgen.dom.Document.createTemplate('mytemplate','pdf');
2. <https://www.mathworks.com/help/rptgen/ug/create-an-html-template.html Unzip the template>, for example:
>> unzipTemplate('mytemplate.pdftx')
3.<https://www.mathworks.com/help/rptgen/ug/modify-styles-in-pdf-templates.html#bu7zyyw-1 Modify the styles>, for example:
Add the following text to the "root.css" file in ../mytemplate/stylesheets
span.RedItalic {
font-style: italic;
color:Tomato;
}
span.Strong{
font-weight: bold;
}
4. Zip the template back up, for example:
>> zipTemplate('mytemplate.pdftx')
5. Use the defined styles in the report, for example:
import mlreportgen.report.*;
import mlreportgen.dom.*;
doc = Report('newreport','pdf', 'mytemplate');
list = OrderedList({Text('This is normal text'),...
Text('This is bold text', 'Strong'),...
Text('This is red italic text', 'RedItalic')});
add(doc, list)
close(doc);
Similar workflow applies to HTML templates as well.
Best Answer