Movatterモバイル変換


[0]ホーム

URL:


mPDF Manual – mPDF functions

IndexEntry()

(mPDF ≥ 2.2)

IndexEntry – Insert an Index entry for the document

Description

voidIndexEntry (string$content[ , string$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 indexas forIndexEntrySee().

Note: The Index must be generated explicity at the end of the document usingInsertIndex() at some point beforeOutput() is called.

Note: Prior to mPDF 2.2 the functionReference() was used.IndexEntry() is now the preferred form.

Parameters

$content

This parameter sets the text as it will appear in the Index entry.

$content cannot contain any of the characters:<,>,&,' or" andmust use the appropriate HTML entities e.g.<annotation content="This is &amp;lt; 40" />

It is recommended that you usehtmlspecialchars('Content', ENT_QUOTES) for this.

Text entries passed in the formSubject:Subcategory will appear in the Index as “Subject, Subcategory”

REQUIRED

$xref

This parameter sets the text used as a cross-reference. Text should be UTF-8 encoded.

$xref cannot contain any of the characters:<,>,&,' or" andmust use the appropriate HTML entities e.g.<indexentry xref="&amp;lt; 40" />

It is recommended that you use e.g.htmlspecialchars($xref, ENT_QUOTES) for this.

Text entries passed in the formSubject:Subcategory will appear in the Index as “Subject, Subcategory”

OPTIONAL

Changelog

VersionDescription
3.0$xref parameter added.

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>',\Mpdf\HTMLParserMode::HTML_BODY);$mpdf->CreateIndex(2,'','',3,1,'',5,'serif','sans-serif');$mpdf->Output();

Example #2

<?php$mpdf->IndexEntry("Dromedary","Camel:types");// This will produce an entry in the Index under 'Dromedary' appearing as:Dromedary-seeCamel,types

Notes

Note: <indexentry> may be a preferred form, 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:

...thisisaword<indexentry.../>inthemiddleoftexttobemarked...

See Also


[8]ページ先頭

©2009-2026 Movatter.jp