Skip to main navigation Skip to main content Skip to page footer

Fluid FPDF Tutorial Custom Index

<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
      xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
      xmlns:fpdf="http://typo3.org/ns/CodingMs/FluidFpdf/ViewHelpers"
      data-namespace-typo3-fluid="true">
<fpdf:pdf>
    <fpdf:setFont family="Arial" style="" size="15" />

    <fpdf:addPage />
    <!-- Add an empty page -->

    <fpdf:addPage />
    <fpdf:bookmark title="Section 1" isUTF8="false" />
    <fpdf:cell width="0" height="6" text="Section 1" />
    <fpdf:ln height="10" />
    <fpdf:bookmark title="Subsection 1" isUTF8="false" level="1" y="-1" />
    <fpdf:cell width="0" height="6" text="Subsection 1" />
    <fpdf:ln height="50" />
    <fpdf:bookmark title="Subsection 2" isUTF8="false" level="1" y="-1" />
    <fpdf:cell width="0" height="6" text="Subsection 2" />

    <fpdf:addPage />
    <fpdf:bookmark title="Section 2" isUTF8="false" />
    <fpdf:cell width="0" height="6" text="Section 2" />
    <fpdf:ln height="10" />
    <fpdf:bookmark title="Subsection 3" isUTF8="false" level="1" y="-1" />
    <fpdf:cell width="0" height="6" text="Subsection 3" />

    <fpdf:goToPage number="1" />
    <fpdf:setXY x="10" y="20" />
    <fpdf:cell width="0" height="6" text="Index" />
    <fpdf:ln height="10" />

    <fpdf:variable.set name="indexEntries" value="{fpdf:getIndex()}" />
    <fpdf:variable.set name="indexStartX" value="30" />
    <fpdf:variable.set name="indexIndentX" value="10" />
    <f:if condition="{f:count(subject: indexEntries)}">
        <f:for each="{indexEntries}" as="indexEntry">
            <!-- Calculate x position -->
            <fpdf:variable.set name="indexEntryX" value="{fpdf:math.product(a: indexIndentX, b: indexEntry.l)}" />
            <fpdf:variable.set name="indexEntryX" value="{fpdf:math.sum(a: indexEntryX, b: indexStartX)}" />
            <!-- Calculate y position -->
            <fpdf:variable.set name="indexStartY" value="{fpdf:getY()}" />
            <fpdf:variable.set name="indexEntryY" value="{fpdf:math.sum(a: indexStartY, b: 10)}" />
            <!-- Print entry -->
            <fpdf:setXY x="{indexEntryX}" y="{indexEntryY}" />
            <fpdf:cell text="{indexEntry.t} (Seite {indexEntry.p})" align="L" width="120" />
        </f:for>
    </f:if>

    <!-- ATTENTION: Don't forget to go back to last page!!! -->
    <fpdf:goToPage />

</fpdf:pdf>
</html>
Dokumentation

TYPO3 Fluid-FPDF

Diese Erweiterung bietet Dir einen vollständigen Satz von ViewHelpern für den Umgang mit FPDF mithilfe von Fluid. Du kannst die ViewHelper einfach in eigenen Erweiterungen verwenden, indem Du einfach den fpdf-Namespace definierst. Zusätzlich kannst du das eingebaute Plugin verwenden, um vordefinierte PDF anzuzeigen. Dieses Plugin bietet Dir automatisch alle verfügbaren PDFs.

Menü