Effacer les filtres
Effacer les filtres

MatLab Report Generator Word Wrap Issues

12 vues (au cours des 30 derniers jours)
Matt O'Brien
Matt O'Brien le 25 Nov 2022
Commenté : Matt O'Brien le 11 Déc 2022
I have a pdf generated via MatLab Report Generator. I have a few remaining issues. I have spent days trying to resolve via search of this and other forums.
I am posting each issue individually.
This issue. Word Wrap at the end of a line in a table.
I am successfully populating a table with text and the table is placed as I wish on the page. The problem is that words are truncated at the end of a line and then continue on the next. I wish to use the behaviour where words are not split at the end of a line before any combination of cr/lf.
Ps. These settings make no difference.
MyDescrTbl.Style = {Hyphenation(true)};
or
MyDescrTbl.Style = {Hyphenation(false)};

Réponse acceptée

Sameer Pujari
Sameer Pujari le 28 Nov 2022
Hi Matt
To get the text to wrap to the second line by separating at a "space" rather than in the middle of a word when using the MATLAB Report Generator, you need to customize the default PDF template used by performing the following:
1. Create a new PDF template from the default PDF template:
>> mlreportgen.dom.Document.createTemplate('mytemplate','pdf');
2. This creates a new PDF template file, "mytemplate.pdftx". Then unzip the template, to gain access to the "root.css" file which allows you to define PDF styles:
>> unzipTemplate('mytemplate.pdftx')
3. In the new folder that is created go to the "stylesheets" folder and open "root.css" to edit in MATLAB or in a text editor.
4. Add the following style to the "table" entry in the CSS file:
-ah-word-break: keep-all
5. Save the CSS file and now zip the template to create an updated "mytemplate.pdftx" file:
>> zipTemplate('mytemplate.pdftx');
6. Then create a "Report" object, by passing the new template as an input argument:
>> d = Report("mydoc","pdf", "mytemplate.pdftx");
For more information on creating a PDF template please visit the following documentation link:
For more information on the different styles you can modify for a PDF template please visit the following documentation link:
  3 commentaires
Matt O'Brien
Matt O'Brien le 28 Nov 2022
I am seriously impressed with this response and also delightesd to see the links to the related documentation. Thank you.
Matt O'Brien
Matt O'Brien le 11 Déc 2022
Here is where I inserted the code in the CSS file.
I inserted line 182 as recommended above.
I am eternally grateful for this solution. It has worked for all the samples I have tested.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by