mPDF Manual – HTML control tags

# 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(). ## 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="&lt; 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="&lt; 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

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: