Text Wrap Problem in Paragraph and Text Components- Report Generator

5 views (last 30 days)
Hi,
Im using the Report Generator through an m-file code to generate a dynamic report. In the Paragraph and Text components, Im setting IsLietral=True to print a string variable formatted through sprintf function. With this, everything prints fine except the text lines are not getting wrapped and lines go way beyond the horizontal visible area and one has to scroll horizontally to view complete text. If i turn the IsLiteral=False, text wraps fine but the string formatting is lost.
Plz advise how to solve this problem.
I wonder why cant Matlab offer some options like "Paragraphs defined by line breaks" in paragraph and Text components as well as it already provide a similar option in its File Import component?
Here is my sample code:
RptgenML_CReport1 = RptgenML.CReport('Stylesheet','!html-SinglePage');
%Create rptgen.cfr_section rptgen_cfr_section1 = rptgen.cfr_section('SectionTitle', 'This is First Chapter');
setParent(rptgen_cfr_section1,RptgenML_CReport1);
%This is my formatted string, a bit too long
myvar=sprintf('Setup Hierarchy\nA report setup has a hierarchical structure that generally mirrors the structure of the type of report that it defines.\nFor example, a report typically has a title page and one or more chapters. Each chapter contains one or more sections, each of which contains one or more paragraphs, figures, tables, lists, etc. A report setup typically comprises components that correspond to these structural elements of a report.\nIn a report setup, child-parent relationships among the components correspond to the containment relationships among the structural elements of the report. In particular, all setups contain a root component that serves as the ancestor for all other components in the setup. The root component also specifies the setup name and report generation options, such as the document type of the generated report (for example, HTML or PDF) and the path for the generated report. The root component typically parents a title page component and one or more chapter components that in turn parent one or more section components that parent one or more paragraph, figure, table, and list components.\n\n')
%Create rptgen.cfr_paragraph
rptgen_cfr_paragraph1 = rptgen.cfr_paragraph('ParaTitle','Abstract', 'TitleType','specify');
rptgen_cfr_text3 = rptgen.cfr_text('isLiteral',true,'isBold',true, 'isItalic',true,'Content',myvar);
set(rptgen_cfr_paragraph1,'ParaTextComp',rptgen_cfr_text3);
setParent(rptgen_cfr_paragraph1,rptgen_cfr_section1);
  2 Comments
Aubai
Aubai on 19 Jan 2021
any lcuk on this issue?
I have the same problem and i am not sure how to slove it!!!
I have Matlab 2019b
Matt O'Brien
Matt O'Brien on 28 Nov 2022
Same here. It renders the Report Generator useless. I also tried Wordwrap, which did not work for me.
I tried placing text into a table cell as well as formatting as a Paragraph and then inserting into a table. In all cases words are split at the end of a line and the remaining letters carried over to the next line.
I have also experimented with using the Hyphen related parameter. No luck.
I accept I may be missing some syntax or setting and there may be some combo that works, but this should be default behaviour.

Sign in to comment.

Answers (1)

Chad Greene
Chad Greene on 23 Sep 2015
The wraptext function may help.

Community Treasure Hunt

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

Start Hunting!