# PDF editor

The PDF editor allows the user to create templates for the PDF output.
These templates are saved as files in config/pdf.

## Pdfmain.php

This is the start page of the PDF editor. The user can select to add/modify/remove selected PDF profiles.
The list of existing PDF profiles is returned by getPDFStructureDefinitions() in pdfstruct.inc. It includes all structure names without file extensions for a given account type.
Depending on the selection of the user he is forwarded to pdfpage.php or pdfdelete.php.

## Pdfpage.php

The user can edit the PDF structures on this page.
The structure is loaded with loadPDFStructureDefinitions() from pdfstruct.inc. If it does not yet exist then the default structure is loaded.
It is stored in $_SESSION['currentPDFStructure'] (sections) and $_SESSION['currentPageDefinitions'] (head line and logo).
At the top of the page the head line and logo can be edited. The list of available logos is retrieved with getAvailableLogos() from pdfstruct.inc.
The sections on the left side are displayed like they are defined in $_SESSION['currentPDFStructure']. Each item has links to move or delete it. Section titles may be changed.
The list of available PDF entries on the right side is retrieved from getAvailablePDFFields() in modules.inc.
Near the bottom there the user can add a new section. The list of available PDF entries is retrieved as above.
When the user pushes one of the buttons or clicks on a link then there are several actions:

- Abort button: The user is redirected back to pdfmain.php.
- Save button: The structure name is checked for correctness and the file is saved with savePDFStructureDefinitions() from pdfstruct.inc.
- Add section button: LAM adds a static text or section to the structure.
- Add entry button: Adds a new entry to the selected section.
- Change name button: Changes the name of the section title or the section attribute.
- Remove entry link: If the entry is a section then all parts of this section are removed. Otherwise a single entry is removed.
- Move up/down links: The entry or section is moved up or down.

$_SESSION['currentPDFStructure'] is an array that contains all XML tags of the PDF structure. If you want to modify the structure always remember to put the opening and closing tags at the right place.

## Pdfdelete.php

When the user selected to delete a structure in pdfmain.php he is redirected to this page.
LAM will ask once again if the user is sure to delete the structure. If this is the case the structure will be deleted with deletePDFStructureDefinition() from pdfstruct.inc.