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>
Documentation

TYPO3 Fluid-FPDF by coding.ms

This extension provides a comprehensive set of ViewHelpers for working with FPDF in Fluid. By defining the fpdf namespace, you can generate PDFs directly in your own TYPO3 extensions. It also includes a built-in plugin for rendering predefined PDFs, automatically exposing all available PDF definitions. Additional features include barcode generation, text rotation, PDF/A-3b support, as well as ZUGFeRD and Factur-X compatibility (e-invoice).

Menu