indexentry
(mPDF ≥ 1.0)
indexentry – Insert an Index entry for the document
Description
<indexentry $content [ $xref ] />
Insert an Index entry for the document Index, referencing the current writing position in the document. If $xref is set, it will appear as a cross-referencing entry in the index as for IndexEntrySee().
Note: The Index must be generated explicity at the end of the document using CreateIndex() at some point before Output() is called.
Attributes
- $content
-
This attribute sets the text as it will appear in the Index entry. Text should be UTF-8 encoded.
$content cannot contain any of the characters:
<
,>
,&
,'
or"
and must use the appropriate HTML entities e.g.<indexentry content="< 40" />
It is recommended that you use
htmlspecialchars('Content', ENT_QUOTES)
for this.REQUIRED
- $xref
-
This attribute sets the text used as a cross-reference. Text should be UTF-8 encoded.
$xref cannot contain any of the characters:
<
,>
,&
,'
or"
and must use the appropriate HTML entities e.g.<indexentry xref="< 40" />
It is recommended that you use e.g.
htmlspecialchars($xref, ENT_QUOTES)
for this.Text entries passed in the form
xref="Subject:Subcategory"
will appear in the Index as “Subject, Subcategory”OPTIONAL
Changelog
Version | Description |
---|---|
3.0 | $xref attribute added. |
Examples
Example #1
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('Beginning bit of document...');
$mpdf->WriteHTML('Your text which refers
to a buffalo,<indexentry content="Buffalo" /> which you would like to see in the Index');
$mpdf->AddPage();
$mpdf->WriteHTML('<h2>Index</h2>', \Mpdf\HTMLParserMode::HTML_BODY);
$mpdf->CreateIndex(2, '', '', 3, 1, '', 5, 'serif','sans-serif');
$mpdf->Output();
Example #2
<?php
$mpdf->WriteHTML('<indexentry content="Dromedary" xref="Camel:types" />The dromedary
is a type of camel');
// This will produce an entry in the Index under 'Dromedary' appearing as:
// Dromedary - see Camel, types
Notes
Note:
<indexentry>
may be a preferred form to
IndexEntry(),
as it will allow more precise identification of the position and page - the <indexentry>
can be placed
just next to the appropriate word.
Recommended placement
Recommended placement of Index Entries is just after the first word following the opening tag of the block element:
<h2>First<indexentry... /> word of a heading or block</h2>
or alternatively just after the opening tag of the block element:
<h2><indexentry... />Heading or block</h2>
or just after a word to be marked:
... this is a word<indexentry... /> in the middle of text to be marked ...
See Also
- IndexEntry() - Mark an Index entry in the document
- CreateIndex() - Generate a document Index