mlreportgen.dom.WhiteSpace Class
R2026bNamespace: mlreportgen.dom
White space type
Description
Specifies behavior for white space and line breaks in text.
The mlreportgen.dom.WhiteSpace class is a handle class.
Creation
Description
Input Arguments
White-space behavior, specified as one of these values.
Note
Only "preserve" and "normal" affect Word
output.
| Value | Description |
|---|---|
| For HTML and PDF, removes leading and trailing spaces and collapses multiple spaces in text to a single space, ignoring line breaks. For Word, removes leading and trailing spaces, ignoring line breaks. |
| Sequences of white spaces collapse into a single white space. Text
does not wrap to the next line. The text continues on the same line until a
|
| Preserves white space. Text wraps only on line breaks. Acts like
the |
| Preserves spaces and line breaks. |
| Sequences of white spaces collapse into a single white space. Text wraps if necessary and on line breaks. |
| Preserves white space. Text wraps if necessary and on line breaks. |
Properties
White-space option, specified as one of the values in the option
input argument.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Tag, specified as a character vector or string scalar. The DOM API generates a
session-unique tag as part of the creation of this object. The generated tag has the
form CLASS:ID, where
CLASS is the object class and
ID is the value of the
Id property of the object. Use this value to help identify
where an issue occurs during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Examples
This example shows the effect of using the "preserve" option for each of the output formats. Preserving the trailing space is useful, for example, if you are creating a chapter title. Typically, you append an autonumber after the text "Chapter: ". Using "preserve" keeps the trailing space.
HTML Output
When you choose HTML as the output format, the multiple spaces collapse but the output preserves the trailing space.
import mlreportgen.dom.*; doctype = "html"; d = Document("testHTML",doctype); open(d); p = Paragraph(... "This paragraph has extra spaces and one after the colon: "); % p.Style = {WhiteSpace("preserve")}; append(p,"XX"); append(d,p); close(d); rptview(d.OutputPath);
Word Output
When you choose Word as the output format, the multiple spaces do not collapse and the output preserves the trailing space. Try commenting out the WhiteSpace property. The output preserves the multiple spaces, but removes the trailing space after the colon.
import mlreportgen.dom.*; doctype = "docx"; d = Document("test",doctype); open(d); p = Paragraph(... "This paragraph has extra spaces and one after the colon: "); p.Style = {WhiteSpace("preserve")}; append(p,"XX"); append(d,p); close(d); rptview(d.OutputPath);
PDF Output
Description of second code block
import mlreportgen.dom.*; doctype = "pdf"; d = Document("test",doctype); open(d); p = Paragraph(... "This paragraph has extra spaces and one after the colon: "); p.Style = {WhiteSpace("preserve")}; append(p,"XX"); append(d,p); close(d); rptview(d.OutputPath);
Version History
Introduced in R2014bParagraph text in DOCX output now preserves
leading and trailing white space by default. In earlier releases, DOCX output removed
leading and trailing white space unless the WhiteSpace
property was set to "preserve". To restore the previous behavior,
set WhiteSpace to "normal".
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)