CreateIndex()
(mPDF ≥ 2.2)
CreateIndex — Generate an Index for the document
Note: This function is removed in mPDF v6.0 and replaced by InsertIndex()
Description
void CreateIndex ( [ int $numberofcolumns [, float $fontsize [, float $linespacing [, float $offset [, int $usedivletters [, float $divlettersfontsize [, float $columngap [, string $font [, string $divletterfont [, boolean $uselinking ]]]]]]]]])
Inserts an Index for the document based on index entries made using <indexentry> or IndexEntry().
Note: Prior to mPDF 2.2 the function CreateReference()
was used. This function was replaced by CreateIndex()
untill mPDF 6.0.
Since mPDF 6.0 InsertIndex() is the preferred form.
Note: $uselinking was added in mPDF 3.0
Parameters
- $numberofcolumns
-
Set the number of (vertical) columns to use for the Index
BLANK or omitted or
0
or1
uses the whole page is used as one column.Default:
1
- $fontsize
-
Sets the font size for the Index in points (pt)
BLANK or omitted or
0
uses the default font-size for the document. - $linespacing
-
Sets the line-height used for index entries. Usual values between
1.0
and1.4
.BLANK or omitted or
0
uses the default value.Default:
1.2
(changed from1.0
in mPDF < 3.0) - $offset
-
Sets the text indent (in mm) for subsequent lines, if an index entry flows onto two or more lines.
BLANK or omitted uses a default value of 3 mm.
- $usedivletters
-
Defines whether to divide index entries starting with the same letter, using a (large) letter as a heading.
Default:
1
Values
1
: show dividing letters in the Index0
: do not show dividing letters in the Index
BLANK or omitted uses a default value of
1
- $divlettersfontsize
-
Sets the font size for the dividing letters in points (pt)
BLANK or omitted or
0
uses the 1.8 times the default font-size for the document. - $columngap
-
Sets the gap between columns (if set) in millimeters.
BLANK or omitted uses the default value.
Default:
5
(mm) - $font
-
Set the font-family for the Index.
BLANK or omitted uses default font-family for the document.
- $divletterfont
-
Set the font-family for the dividing letters in the Index.
BLANK or omitted uses default font-family for the document.
- $uselinking
-
Specify whether to add hyperlinks (internal links) to the entries in the document Index.
true
or1
: add links to Index- BLANK or omitted,
0
orfalse
: do not add links to the Index - Default:
false
Changelog
Version | Description |
---|---|
2.2 | Function was added as a synonym for CreateReference(). |
3.0 | $uselinking parameter was added |
3.0 | Default value for $linespacing changed to 1.2 |
Examples
Example #1
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('
Beginning bit of document...
');
$mpdf->IndexEntry("Buffalo");
$mpdf->WriteHTML('
Your text which refers to a buffalo, which you would like to see in the Index
');
$mpdf->AddPage();
$mpdf->WriteHTML('<h2>Index</h2>',2);
$mpdf->CreateIndex(2, '', '', 3, 1, '', 5, 'serif','sans-serif');
$mpdf->Output();
Note: There is no HTML equivalent of CreateIndex()
See Also
- Replacement: InsertIndex() - Generate an Index for the document
- IndexEntry() - Add an Index entry in the document
- <indexentry> - Mark an Index entry in the document