textObj = append(targetObj,text) converts text to
an mlreportgen.dom.Text object, appends the text
to the link target, and returns the text object.
textObj = append(targetObj,text,styleName) converts text to
an mlreportgen.dom.Text object, appends the text
to the link target, and returns the text object.
This example creates a two-page document with a link to a target at the top of the document.
Create a link target 'home' and append text to it. After a page break, create a link to the target, using InternalLink. 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);
Append an Automatically Generated Number to a Link Target
This example creates a two-page document with
an autonumber appended to the link target.
Create a paragraph and define an autonumber. Append the
autonumber 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);