mlreportgen.dom.LinkTarget Class
Namespace: mlreportgen.dom
Target for internal or external links or image area links
Description
Use an object of the mlreportgen.dom.LinkTarget class to specify a target to use for internal and external links and for image area
links. You can specify a LinkTarget object when you construct an
mlreportgen.dom.InternalLink or
mlreportgen.dom.ImageArea object.
To see what DOM objects you can append an mlreportgen.dom.LinkTarget object to, see
Append mlreportgen.dom.LinkTarget object to DOM class object.
The mlreportgen.dom.LinkTarget class is a handle class.
Creation
Input Arguments
Name of a link target, specified as a character vector or string scalar.
Note
To generate a link target name that is valid for all report types, use mlreportgen.utils.normalizeLinkID. The generated name conforms to the
Microsoft® Word limitation on ID length and the PDF requirement that an ID begin with
an alphabetic character.
Word replaces spaces in link target names with underscore characters. Avoid spaces in link target names in Word reports.
To set up a link target for an external link:
In a Word report, specify a Word bookmark.
In an HTML report, specify an HTML named anchor (for example,
<a name="appendix"/>).
Properties
Name of a link target, specified as a character vector or string scalar.
For more information on name requirements, see the name input argument.
Attributes:
GetAccess | public |
SetAccess | none |
NonCopyable | true |
Transient | true |
Whether this object is the target of an mlreportgen.dom.XRef object
in an mlreportgen.dom.Document or
mlreportgen.report.Report object of type PDF, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Object is a target of anXrefobject.0(false) — Object is not a target of anXrefobject.
For example see Use Cross-Reference Elements in a PDF Report.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: logical
The style specified by styleName must be defined in the
template used to create the document element to which this link target is
appended.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Format specification for this document element object, specified as a cell 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 |
Data Types: cell
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 |
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
Method | Purpose |
|---|---|
|
Input Arguments
Return Values
To see a list of the DOM class objects
and MATLAB data types you can use as the
For more information, see the equivalent |
clone |
Note Do not append the same object to a document more than once. Use clone to create a copy when you want to reuse the same content elsewhere in a document. Input Arguments
Return Values
For more information, see the equivalent method for the
|
Examples
Define a link target at the top of the report and add an internal link to that target.
import mlreportgen.dom.* import mlreportgen.utils.* d = Document("mydoc","pdf"); p = Paragraph("This is my paragraph"); linkID = normalizeLinkID("home"); append(p,LinkTarget(linkID)); append(d,p); p = Paragraph("This is another paragraph"); p.Style = {PageBreakBefore(true)}; append(d,p); append(d,InternalLink(linkID,"Go to Top")); close(d); rptview(d);
This example creates a two-page document with a link to a target at the top of the document.
Create a link target named "home" and append text to it. After a
page break, create a link to the target. The text for the link is Go to
top.
import mlreportgen.dom.* d = Document("mydoc","pdf"); target = LinkTarget("home"); append(target," - top of page"); append(d,target); p = Paragraph("This is another paragraph"); p.Style = {PageBreakBefore(true)}; append(d,p); append(d,InternalLink("home","Go to top")); close(d); rptview(d.OutputPath);
This example creates a two-page document with an automatically generated number appended to the link target.
Create a paragraph and define an automatically generated number. Append the number to the target and append the target to the paragraph. After the page break, create a link to the target.
import mlreportgen.dom.* d = Document("mydoc","docx"); p = Paragraph("Chapter "); p.Style = {CounterInc("chapter"),WhiteSpace("preserve")}; number = AutoNumber("chapter"); target = LinkTarget("chapno"); append(target,number); append(p,target); append(d,p); p = Paragraph("Paragraph on another page"); p.Style = {PageBreakBefore(true)}; append(d,p); append(d,InternalLink("target","Chapter reference")); close(d); rptview(d.OutputPath);
More About
You can append these DOM objects to an
mlreportgen.dom.LinkTarget object:
You can append these MATLAB data types to an
mlreportgen.dom.LinkTarget object:
character array — Appends and returns a
mlreportgen.dom.Textobjectstring scalar — Appends and returns a
mlreportgen.dom.Textobjectnumeric variable — Appends and returns a
mlreportgen.dom.Numberobjectlogical variable — Appends and returns a
mlreportgen.dom.Numberobject with a value of1or0
You can append an mlreportgen.dom.LinkTarget object to
these DOM class objects:
mlreportgen.dom.Endnote(since R2024a)mlreportgen.dom.Footnote(since R2024a)mlreportgen.dom.HTMLPage(since R2024a)mlreportgen.dom.TemplateDocumentPart(since R2023b)
Version History
Introduced in R2014bIn a future release, a link target name (ID) generated by mlreportgen.utils.hash might not be valid for PDF reports. To ensure that a
link target name is valid for all report types, use
mlreportgen.utils.normalizeLinkID instead of
mlreportgen.utils.hash.
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)