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 by coding.ms

Diese Extension bietet einen umfangreichen Satz an ViewHelpern zur Arbeit mit FPDF in Fluid. Nach Einbindung des fpdf-Namespaces kannst Du PDFs direkt in eigenen TYPO3-Extensions erzeugen. Zusätzlich steht ein integriertes Plugin zur Ausgabe vordefinierter PDFs bereit, das verfügbare PDF-Definitionen automatisch bereitstellt. Unterstützt werden außerdem Barcode-Generierung, Text-Rotation, PDF/A-3b sowie ZUGFeRD und Factur-X (E-Rechnung).

Menü