mlreportgen.dom.Preformatted Class
Namespace: mlreportgen.dom
Superclasses: mlreportgen.dom.Paragraph
Preformatted block of text
Description
Use objects of the mlreportgen.dom.Preformatted class to preserve the
      white-space formatting of text. White space-formatting uses spaces, line feeds, and monospace
      fonts to render text on multiple lines and to control indentation. For example, use an
        mlreportgen.dom.Preformatted object to add program code to a report.
If you do not set the FontFamilyName or Whitespace
      properties, the DOM API uses the default values for the report type (HTML, Microsoft® Word, or PDF) so that white-space formatting is preserved. You can override the
      default values by setting the FontFamilyName or
        Whitespace properties.
The mlreportgen.dom.Preformatted class is a handle class.
Class Attributes
| ConstructOnLoad | true | 
| HandleCompatible | true | 
For information on class attributes, see Class Attributes.
Creation
Description
preObj = mlreportgen.dom.Preformatted
preObj = mlreportgen.dom.Preformatted(text)
preObj = mlreportgen.dom.Preformatted(docElementObj)docElementObj.
Input Arguments
Paragraph text, specified as a character vector or string scalar.
Style for this paragraph, specified as a character vector or string scalar. The style must be defined in the template used to create the document to which this paragraph is appended.
Document element (DOM object) to include in this paragraph. You can specify these DOM objects:
Properties
Background color that contains a CSS color name or a hexadecimal RGB value, specified as a character vector or string scalar.
- To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords. 
- To specify a hexadecimal RGB format, use - #as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example,- "#0000ff"specifies blue.
Note
Setting the BackgroundColor property adds a
                    mlreportgen.dom.BackgroundColor format object to the
                    Style property. Setting the
                    BackgroundColor property to an empty value removes the
                object.
Example: "blue"
Example: "#0000ff"
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Option to use bold for this document element, specified as a numeric or logical
                1 (true) or 0
                (false). To make document element bold, set
                Bold to true or 1. 
Note
Setting the Bold property adds a corresponding
                    mlreportgen.dom.Bold format object to the
                    Style property. Setting the Bold property
                to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: logical
Document element object color, specified as a character vector or string scalar that contains a CSS color name or hexadecimal RGB value.
- To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords. 
- To specify a hexadecimal RGB format, use - #as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example,- "#0000ff"specifies blue.
Note
Setting the Color property adds a corresponding
                                        mlreportgen.dom.Color format object to the
                                        Style property. Setting the
                                        Color property to an empty value removes
                                the object.
Example: "blue"
Example: "#0000ff"
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Indentation amount for the fist line of this paragraph that consists of number followed by an abbreviation for a unit of measurement, specified as a character vector or string scalar. For example, "0.5in" specifies one-half inch. Valid abbreviations are:
- "px"— Pixels
- "cm"— Centimeters
- "in"— Inches
- "mm"— Millimeters
- "pc"— Picas
- "pt"— Points
The indentation amount is the amount by which to indent the first line of this paragraph relative to the succeeding lines. To create a hanging indent where all of the lines are indented except for the first line, use a negative number.
Note
Setting the FirstLineIndent property adds a corresponding
                    mlreportgen.dom.FirstLineIndent format object to the
                    Style property for this document element. Setting the
                    FirstLineIndent property to an empty value removes the
                object.
Example: "0.5in"
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Name of a font family to use for text, specified as a character vector or string scalar. To
                                    specify substitutions for the font, do not specify the font
                                    family by setting this property. Instead, create and add an
                                                mlreportgen.dom.FontFamily object
                                    to the Style property.
Note
Setting the FontFamilyName property
                                                adds a corresponding
                                                  mlreportgen.dom.FontFamily
                                                format object to the Style
                                                property. Setting the
                                                  FontFamilyName property is the
                                                same as setting the FontName
                                                property of an
                                                  mlreportgen.dom.FontFamily
                                                object. Setting the
                                                  FontFamilyName property to an
                                                empty value removes the object.
Example: "Courier New"
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Font size to use for document element that contains a number followed by an
            abbreviation for a unit of measurement, specified as a character vector or string
            scalar. For example, "12pt" specifies twelve points. Valid
            abbreviations are:
- "px"— Pixels
- "cm"— Centimeters
- "in"— Inches
- "mm"— Millimeters
- "pc"— Picas
- "pt"— Points
Note
Setting the FontSize property adds a corresponding
                    mlreportgen.dom.FontSize format object to the
                    Style property. Setting the FontSize
                property to an empty value removes the object.
Example: "12pt"
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Horizontal alignment for this paragraph, relative to page margins or table cell borders, specified as one of the values in this table.
| Value | Description | Supported Output Types | 
|---|---|---|
| 
 | Center the paragraph. | All | 
| 
 | Distribute all characters equally. | Word | 
| 
 | Align left side of paragraph on left side of page or table entry, and right side of paragraph on the right side of the page or table entry. | All | 
| 
 | Use widest Kashida length. Kashida is a type of justification used for some cursive scripts, such as Arabic and Persian. | Word | 
| 
 | Use lowest Kashida length. | Word | 
| 
 | Use medium Kashida length. | Word | 
| 
 | Align paragraph left. | All | 
| 
 | Align paragraph right. | All | 
| 
 | Thai language justification. | Word | 
Note
Setting the HAlign property adds a corresponding
                    mlreportgen.dom.HAlign format object to the
                    Style property for this document element. Setting the
                    HAlign property to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Outline level of the paragraph, specified as an integer. Setting the
                OutlineLevel property causes this paragraph to be included in
            automatically generated outlines, such as a table of contents. The value specifies the
            level of the paragraph in the outline. For example, to make a paragraph appear at the
            top level in an outline, set the OutlineLevel property to
                1.
Note
Setting the OutlineLevel property adds a corresponding
                    mlreportgen.dom.OutlineLevel format object to the
                    Style property. Setting the OutlineLevel
                property to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: int32
Option to use italic for document element, specified as a numeric or logical
                1 (true) or 0
                (false). To make document element italic, set
                Italic to true or 1. 
Note
Setting the Italic property adds a corresponding
                    mlreportgen.dom.Italic format object to the
                    Style property. Setting the Italic
                property to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: logical
Text strikethrough, specified as one of these values:
- "none"— No strikethrough
- "single"— Single line
- "double"— Double line (for Word reports only)
Note
Setting the Strike property adds a corresponding
                    mlreportgen.dom.Strike format object to the
                    Style property for this document element. Setting the
                    Strike property to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Type of underline, specified as one of the values in this table.
| Underline value | Description | Supported Output Types | 
|---|---|---|
| 
 | Single line | All | 
| 
 | Underline all characters except spaces | Word | 
| 
 | Double line | Word | 
| 
 | Thick line | Word | 
| 
 | Dotted line | Word | 
| 
 | Thick dotted line | Word | 
| 
 | Dashed line | Word | 
| 
 | Line with heavy dashes | Word | 
| 
 | Line with long dashes | Word | 
| 
 | Line with heavy long dashes | Word | 
| 
 | Dot-dash line | Word | 
| 
 | Heavy dash-dot line | Word | 
| 
 | Dot-dot-dash line | Word | 
| 
 | Line with heavy dashes and two dots between the dashes | Word | 
| 
 | Wavy line | Word | 
| 
 | Heavy wavy | Word | 
| 
 | Double wavy line | Word | 
| 
 | No underline | All | 
To specify both the color and the type of the underline, do not set the Underline property. Instead, set the Style property to include an mlreportgen.dom.Underline format object that specifies the underline type and color.
Note
Setting the Underline property adds a corresponding
                    mlreportgen.dom.Underline format object to the
                    Style property. Setting the Underline
                property to an empty value removes the object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
How to treat white space and line breaks in text, specified as one of the values in
            this table. The WhiteSpace property does not apply when the
                Type property of the Document object is
            PDF.
| Value | Description | Supported Output Types | 
|---|---|---|
| 
 | For HTML and PDF, this value removes spaces at the beginning and the end of text. Multiple spaces in the text collapse to a single space. For Microsoft Word, this value removes spaces at the beginning and end of text. | All | 
| 
 | Sequences of white space collapse into a single white space. Text never wraps to the next line. | HTML | 
| 
 | Preserves white space. Text wraps only on line breaks. Acts
                                like the  | HTML and PDF | 
| 
 | Same as "pre". | All | 
| 
 | Sequences of white space collapse into a single white space. Text wraps when necessary and on line breaks. | HTML and PDF | 
| 
 | Preserves white space. Text wraps when necessary and on line breaks. | HTML and PDF | 
Note
Setting the WhiteSpace property adds a corresponding mlreportgen.dom.WhiteSpace format
                object to the Style property. Setting the
                    WhiteSpace property to an empty value removes the
                object.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Name of stylesheet-defined style, specified as a character vector or string scalar.
            The style name is the name of a style specified in the style sheet of the document or
            document part to which this element is appended. The specified style defines the
            appearance of this element in the output document unless the formats specified by the
                Style property of this element override it. To learn more about
            using style sheets, see Use Style Sheet Styles.
Note
Microsoft Word reports ignore style names that are not defined in the document template. For more information on Microsoft Word templates, seeTemplates for DOM API Report Programs.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Data Types: char | string
Format specification for this document element object, specified as an array of DOM
            format objects. The formats specified by this property override corresponding formats
            specified by the StyleName property of this element. Formats that
            do not apply to this document element object are ignored.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Custom attributes of the document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be
            supported by the output format of the document element to which this object is
            appended.
Attributes:
| GetAccess | public | 
| SetAccess | public | 
| NonCopyable | true | 
Parent of this object, specified as a document element object. A document element must have only one parent.
Attributes:
| GetAccess | public | 
| SetAccess | private | 
| NonCopyable | true | 
Children of this object, specified as an array of document element objects. This
            property contains the document element objects appended using the
                append method.
Attributes:
| GetAccess | public | 
| SetAccess | private | 
| NonCopyable | true | 
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
Methods
Examples
Format code in a report by using an mlreportgen.dom.Preformatted object. The white space and newline characters are preserved in the output. The font of the code is monospace.
import mlreportgen.dom.* import mlreportgen.report.* rpt = Report('myReport','docx'); p = Paragraph("This is my code:"); pr = Preformatted(" a = 1;" + newline + " b = 2;" + newline + " c = a + b;"); add(rpt, p); add(rpt,pr); close(rpt); rptview(rpt);
Here is the code in the generated report:

Version History
Introduced in R2020a
See Also
mlreportgen.dom.Paragraph | mlreportgen.dom.HAlign | mlreportgen.dom.FontFamily | mlreportgen.dom.FontSize | mlreportgen.dom.Bold | mlreportgen.dom.Italic | mlreportgen.dom.Color | mlreportgen.dom.Strike | mlreportgen.dom.Underline | mlreportgen.dom.OuterMargin | mlreportgen.dom.BackgroundColor | mlreportgen.dom.CustomAttribute | mlreportgen.dom.FirstLineIndent | mlreportgen.dom.WhiteSpace
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)