This example shows how to use cross-reference elements in a generated PDF report.
Import these packages so that you do not have to use long, fully qualified class names.
Create an mlreportgen.report.Report
object of type PDF.
Create an mlreportgen.report.Chapter
object for the introduction chapter, and an mlreportgen.dom.Paragraph
object for the content of the introduction chapter.
Use the function normalizeLinkID
to generate a valid unique link ID, then use this link ID to create an mlreportgen.dom.LinkTarget
object.
Create two reference objects, an mlreportgen.dom.XRef
and an mlreportgen.dom.PageRef
, with the same link ID you used to create the LinkTarget
object. You must use the same link ID for all three objects to link the reference objects to the link target object.
Customize the appearance of the cross-reference object by adding an mlreportgen.dom.Italic
object to the Style property.
Set the IsXRefTarget
property of the LinkTarget
object to true. This is necessary only in PDF reports.
Fill the paragraph with content that includes the cross-reference and the page reference objects.
Append the paragraph object to the chapter object, then append the chapter object to the report.
Create another Chapter
object for the information chapter.
Append the text "Information"
to the link target object and set the title of the chapter object to the link target object.
Append the second chapter object to the report. Then close and view the report.
When the report opens, test the cross-reference and page reference elements.