MATLAB Answers

Reportgenerator Template/Styles Matlab 2018b

7 views (last 30 days)
I am trying to include a Style template into my PDF report. When I create a section I use
- TemplateSrc, 'mytemplate'
as parameter.
For mytemplate I took the 'default PDF template' from the report generator GUI. To get it I did that:
Report Explorer (Generator) -> Edit Document Conversation Template -> Default PDF Template -> Copy Template
If I try to use it directly I get the error: Section 1 not found.
So i unzip the default template.pdftx and look into the html files. The only section I can find is:
<dptemplate name="rgSect1Title">
<h2 class="rgSect1Title" style="counter-increment:sect1; counter-reset:sect2">
<hole id="prefix" default-style-name="rgSect1TitlePrefix">prefix</hole>
<hole id="number" default-style-name="rgSect1TitleNumber">number</hole>
<hole id="text" default-style-name="rgSect1TitleText">title</hole>
So I renamed my section to sect with
- TemplateName, 'Sect'
and after that did not work I tried to rename the Sect in the html file to Section. Nothing worked so far. If I set it to Section1 I can generate the report but the Section1 does not show. Maybe the hole ids, styles or what so ever is not set correctly.
So I am wondering how I can create a style with Matlab 2018b for counting up SectionsX within the template correctly.
Thanks a lot


Sign in to comment.

Accepted Answer

Rahul Singhal
Rahul Singhal on 14 Jul 2020
Edited: Rahul Singhal on 14 Jul 2020
Hi Martin,
It looks like you are using the Report API to create report, but using the Report Explorer application to create the custom template.
In Report API, each reporter has its own default template whose copy can be created by using the reporter's createTemplate() method. For example, if you want to create a copy of the Section reporter's default template, use method.


Show 2 older comments
Martin Meiboom
Martin Meiboom on 16 Jul 2020
Hi Rahul,
Ok. coming back to my actual problem - with you help I could also find a constructor to create the TOC for my template. Unfortunately if the NumberOfLevels exceeds 3 the forth level is not indented and formatted in the standard layout. Is there documentation about the docpart_templates and css? So far I merged both templates (TableOfContents.customizeReporter & createTemplate). I also tried to include the forth layer unfortunately without success.
Thanks again for you help :)
Best regards
Rahul Singhal
Rahul Singhal on 16 Jul 2020
Hi Martin,
Actually the command-line help for TableOfContents reporter was updated in R2019a to address the TOC elements customization issue. To update the TOC elements styles, you need to update the report's template instead of the reporter templete. Below is the actual content from the TableOfContents reporter command-line help:
Styles in a report's template determine the size, spacing, color, and other format properties of the entries in a table of contents generated by this reporter. The object's default Word and PDF templates define styles that determine the default format of TOC entries. The styles are named TOC1, TOC2, ... TOC6, where style TOC1 defines the format of level 1 entries, style TOC2 defines the format of level 2 entries, etc. To change the format of the entries, create a custom report template that redefines these styles and use the template to generate your report. Note that you must redefine the styles in the report template, not in the template used by this reporter.
Hope this helps!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!