EXT: sg_forms_pdf

Adds a PDF finisher to the forms finishers.

Configuration

  1. Create a pdf template record and add a file with your pdf containing form fields to fill.
  2. Find out the name of your form fields either by using Xdebug and setting a breakpoint at the getDataFields() call, or by using pdftk binary directly:
    sudo apt install pdftk
    pdftk sample.pdf dump_data_fields output fields.txt
    
    Where the output look similar to this (taken from xdebug print_r export):
    Array
    (
        [0] => Array
            (
                [FieldType] => Text
                [FieldName] => 1DatumAbgabe
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [1] => Array
            (
                [FieldType] => Text
                [FieldName] => 2Name
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [2] => Array
            (
                [FieldType] => Text
                [FieldName] => 2Vorname
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [3] => Array
            (
                [FieldType] => Text
                [FieldName] => 2BezeichnungVertrag
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [4] => Array
            (
                [FieldType] => Text
                [FieldName] => 2EMail
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [5] => Array
            (
                [FieldType] => Text
                [FieldName] => 2Vertragsnummer
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [6] => Array
            (
                [FieldType] => Text
                [FieldName] => 1UhrzeitAbgabe
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [7] => Array
            (
                [FieldType] => Text
                [FieldName] => 2WunschdatumKündigung
                [FieldFlags] => 0
                [FieldJustification] => Left
            )
    
        [8] => Array
            (
                [FieldType] => Text
                [FieldName] => 2Kündigungszeitpunkt
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
        [9] => Array
            (
                [FieldType] => Text
                [FieldName] => 2GrundKündigung
                [FieldFlags] => 0
                [FieldJustification] => Left
            )
    
        [10] => Array
            (
                [FieldType] => Text
                [FieldName] => 2ArtKündigung
                [FieldFlags] => 2
                [FieldJustification] => Left
            )
    
    )
    
  3. Create a mapping configuration in typoscript, like this:
    plugin.tx_sgformspdf {
        mappings {
            # form identifier)
            kuendigungsformular-3607 {
                # form field identifier => form field name in the pdf
                last_name = 2Name
                first_name = 2Vorname
                contract = 2BezeichnungVertrag
                email = 2EMail
                contract_number = 2Vertragsnummer
                termination_date = 2Kündigungszeitpunkt
                # custom date parsing
                termination_date_wish {
                    type = DATE
                    name = 2WunschdatumKündigung
                }
                type_of_termination = 2ArtKündigung
                reason_of_termination = 2GrundKündigung
                # custom fields
                # (virtual fields, which are generated on the fly, like CURRENT_DATE & CURRENT_TIME)
                customFields {
                    10 {
                        type = CURRENT_DATE
                        name = 1DatumAbgabe
                    }
                    20 {
                        type = CURRENT_TIME
                        name = 1UhrzeitAbgabe
                    }
                }
            }
        }
    }