mPDF Manual – mPDF functions

CreateIndex()

(mPDF >= 2.2)

CreateIndex — Generate an Index for the document

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().

Parameters

$numberofcolumns

Set the number of (vertical) columns to use for the Index

BLANK or omitted or 0 or 1 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 and 1.4.

BLANK or omitted or 0 uses the default value.

Default: 1.2  (changed from 1.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 Index
  • 0: 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 or 1: add links to Index
  • BLANK or omitted, 0 or false: 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();


See Also

Fork me on GitHub