<div id="coach_output_gbu_chart_{{outputId}}">
{% if isBoss %}
    <div class="coach_output_gbu_chart_container_boss" id="coach_output_gbu_chart_{{outputId}}_boss">
        {% for groupid, group in chartdata %}
        <div class="mr-auto coach_output_gbu_chart_button">
            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randInner = random()%} data-target="#demo_{{randInner}}" aria-expanded="false">
                <p class="h5 primary-color">
                    <i class="fas fa-plus ts-accordion-plus"></i>{{group.groupname}}
                </p>         
            </button>
        </div>
        <div id="demo_{{randInner}}" class="collapse mt-2 coach_output_gbu_chart_groups coach_output_gbu_chart_accordion">
            {% for formid, form in group.formdata%}
                <!-- Headline Skala -->
                <h3>{{charttitles[loop.index0]}}</h3>
                {% if charttype == "all" or charttype == "bar" %}
            
                    {% for barchart in form.bar%}
                        {% if barchart.mintn %}
                        <canvas id="coach_output_gbu_chart_bar_{{formid}}_{{groupid}}_{{loop.index0}}" width="400" height="200"></canvas>
                        <br>
                            {% if barchart.subscalesTNNotReached is not empty %}
                            <br>
                            <p>Für die folgende{% if barchart.subscalesTNNotReached | length > 1%}n{% endif %} {% if barchart.subscalesTNNotReached | length == 1%}Subskala{% elseif barchart.subscalesTNNotReached | length > 1%}Subskalen{% endif %} wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht:</p>
                            <ul>
                            {%for question in barchart.subscalesTNNotReached %}<li>"{{question}}"</li>{% endfor %}
                            </ul>
                        <br>
                        {% endif %}
                        <script>
                        var ctx = document.getElementById('coach_output_gbu_chart_bar_{{formid}}_{{groupid}}_{{loop.index0}}').getContext('2d');
                        var myChart = new Chart(ctx, {
                            type: 'bar',
                            plugins: [ChartDataLabels,
                                {
                                    beforeDraw: function(chart, arg, options){
                                       var ctx = chart.ctx;
                                       var xAxis = chart.scales.x;
                                       var yAxis = chart.scales.y;
                                       ctx.fillStyle = "white";
                                       ctx.fillRect(0, 0, chart.width, chart.height);
                                       var chartParts = (yAxis.ticks[yAxis.ticks.length-1].value-yAxis.ticks[0].value)/0.1;
                                       var chartPartsRatio = 1/chartParts;
                                       
                                       {% if mode[formid] == "+-"%}
                                            for(var i=chartParts; i>=1;i--){
                                                var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                if(currentVal<=2.3){
                                                    ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                }
                                                else if(currentVal>2.3 && currentVal<3.7){
                                                    ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                }
                                                else if(currentVal>=3.7){
                                                    ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                }
                                                ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                            }
                                       {% elseif mode[formid] == "-+"%}
                                            for(var i=chartParts; i>=1;i--){
                                                var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                if(currentVal<=2.3){
                                                    ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                }
                                                else if(currentVal>2.3 && currentVal<3.7){
                                                    ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                }
                                                else if(currentVal>=3.7){
                                                    ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                }
                                                ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                            }
                                       {% endif %}
                                   }
                                }
                            ],
                            data: {
                                labels: {{barchart.chartlabels|json_encode|raw}},
                                datasets: [{
                                    label: 'gesamt',
                                    data: {{barchart.gesamt|json_encode|raw}},
                                    backgroundColor: "{{barColorTotal}}",
                                    borderRadius: 3,
                                },
                                {
                                    label: '{{barchart.labels}}',
                                    data: {{barchart.values|json_encode|raw}},
                                    backgroundColor: "{{barColorTeam}}",
                                    borderRadius: 3,
                                }]
                            },
                            options:{
                                scales:{
                                    x:{
                                        ticks:{
                                            autoSkip: false,
                                            font:{
                                                size: 17
                                            }
                                        }
                                    },
                                    y:{
                                        display: true,
                                        max: 5,
                                        min: 1,
                                        ticks:{
                                            font:{
                                                size: 17
                                            }
                                        }
                                    }
                                },
                                plugins:{
                                    title:{
                                        display: true,
                                        text: '{{charttitles[loop.parent.loop.index0]}}',
                                        padding: {
                                            bottom: 15
                                        },
                                        font:{
                                            size: 20
                                        }
                                    },
                                    legend:{
                                        labels:{
                                            font:{
                                                size: 17
                                            }
                                        },
                                        onClick: (e) => e.stopPropagation()
                                    },
                                    tooltip:{
                                        enabled: false
                                    },
                                    datalabels:{
                                        anchor: 'end',
                                        align: 'end',
                                        font:{
                                            size: 17
                                        }
                                    }
                                },

                            }
                        });
                        </script>
                        {% else %}
                            <div class="alert alert-info" role="alert">
                                <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                <p>
                                    Für alle Subskalen der Skala "{{charttitles[loop.parent.loop.index0]}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                </p>
                            </div>
                        {% endif %}
                    {% endfor %}
                {% endif %}
                {% if charttype == "all" or charttype == "line" %}
                    {% for subskala, linechart in form.line %}
                        <div class="coach_output_gbu_boss_subscales">
                            <div class="mr-auto coach_output_gbu_chart_button">
                                <button class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randSubscales = random()%} data-target="#gbu_chart_boss_subscales_{{randSubscales}}" aria-expanded="false">
                                    <p class="h6"><i class="fas fa-plus ts-accordion-plus"></i>Häufigkeiten: {{subskala}}</p>
                                </button>
                            </div>
                            <div id="gbu_chart_boss_subscales_{{randSubscales}}" class="collapse mt-2 coach_output_gbu_chart_subscales coach_output_gbu_chart_accordion">
                                {% for chart in linechart.chart %}
                                {% if chart.mintn %}
                                <canvas id="coach_output_gbu_chart_line_{{formid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}" width="400" height="200"></canvas>
                                <br>
                                <table class="company-table-gesamt">
                                    <tbody>
                                        <tr>
                                            <td class="p-3">
                                                <p class="mb-0"><b>Mittelwert:</b></p>
                                            </td>
                                            <td class="p-3" style="background-color: #{{chart.mean_color}}">
                                                <b>{{chart.mean}}</b>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <br>
                                <br>
                                <script>
                                var ctx = document.getElementById('coach_output_gbu_chart_line_{{formid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}').getContext('2d');
                                var myChart = new Chart(ctx, {
                                    type: 'line',
                                    plugins:[
                                        {
                                            beforeDraw:function(chart, arg, options){
                                                var ctx = chart.ctx;
                                                ctx.save();
                                                ctx.globalCompositeOperation = 'destination-over';
                                                ctx.fillStyle = "white";
                                                ctx.fillRect(0, 0, chart.width, chart.height);
                                                ctx.restore();
                                            }
                                        }
                                    ],
                                    data: {
                                        labels: {{chart.labels|json_encode|raw}},
                                        datasets: [{
                                            data: {{chart.values|json_encode|raw}},
                                            label: '{{group.groupname}}',
                                            lineTension: 0,
                                            fill: true
                                        }]
                                    },
                                    options: {
                                        scales:{
                                            x:{
                                                grid:{
                                                    display: false
                                                },
                                                ticks:{
                                                    font:{
                                                        size: 17
                                                    }
                                                }
                                            },
                                            y:{
                                                display: true,
                                                beginAtZero: true,
                                                grid:{
                                                    display: false,
                                                },
                                                ticks:{
                                                    display: false
                                                }
                                            }
                                        },
                                        elements:{
                                            point:{
                                                radius: 0
                                            }
                                        },
                                        plugins:{
                                            legend:{
                                                display: true,
                                                labels:{
                                                    font:{
                                                        size: 17
                                                    }
                                                },
                                                onClick: (e) => e.stopPropagation()
                                            },
                                            tooltip:{
                                                enabled: false
                                            },
                                            title:{
                                                display: true,
                                                text: '{{chart.charttitle}}',
                                                padding: {
                                                    bottom: 15
                                                },
                                                font:{
                                                    size: 20
                                                }
                                            }
                                        }
                                    }
                                });
                                </script>
                                {% else %}
                                <div class="alert alert-info" role="alert">
                                    <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                    <p>
                                        Für das Item "{{chart.charttitle}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                    </p>
                                </div>
                                {% endif %}
                                {% endfor %}
                            </div>
                        </div>
                    {% endfor %}
                {% endif %}

            {% endfor %}
            
            {% if showPDFDownload or showPDFDownloadBarChart or showPDFDownloadLineChart %}
            <div class="info">
                {% if showPDFDownloadBarChart %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', true, false)">{{pdfDownloadTitleBarChart}}</a></p>
                </div>
                {% endif %}
                {% if showPDFDownloadLineChart %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', false, true)">{{pdfDownloadTitleLineChart}}</a></p>
                </div>
                {% endif %}
                {% if showPDFDownload %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', true, true)">{{pdfDownloadTitle}}</a></p>
                </div>
                {% endif %}
            </div>
            {% endif %}
        </div>
        {% endfor %}
    </div>
{% elseif isKAdmin %}
    {% for firmaid, firma in chartdata%}
    <div class="coach_output_gbu_chart_container_kadmin" id="coach_output_gbu_chart_{{outputId}}_kadmin_{{loop.index0}}">
        <div class="mr-auto coach_output_gbu_chart_button">
            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randOuter = random()%} data-target="#demo_{{randOuter}}" aria-expanded="false">
                <p class="h4 primary-color">
                    <i class="fas fa-plus ts-accordion-plus"></i>{{firma.companyname}}
                </p>
            </button>
        </div>
        <div id="demo_{{randOuter}}" class="collapse mt-2 coach_output_gbu_chart_group_container coach_output_gbu_chart_accordion">

            {% for groupid, group in firma.groups %}
            <div class="mr-auto coach_output_gbu_chart_button">
                <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randInner = random()%} data-target="#demo_{{randInner}}" aria-expanded="false">
                    <p class="h5 primary-color">
                        <i class="fas fa-plus ts-accordion-plus"></i>{{group.groupname}}
                    </p>
                </button>
            </div>
            <div id="demo_{{randInner}}" class="collapse mt-2 coach_output_gbu_chart_groups coach_output_gbu_chart_accordion">

                {% for formid, form in group.formdata%}
                <!-- Headline Skala -->
                    <h3>{{charttitles[loop.index0]}}</h3>
                    {% if charttype == "all" or charttype == "bar" %}

                        {% for barchart in form.bar%}
                            {% if barchart.mintn %}
                            <canvas id="coach_output_gbu_chart_bar_{{formid}}_{{firmaid}}_{{groupid}}_{{loop.index0}}" width="400" height="200"></canvas>
                            <br>
                                {% if barchart.subscalesTNNotReached is not empty %}
                                <br>
                                <p>Für die folgende{% if barchart.subscalesTNNotReached | length > 1%}n{% endif %} {% if barchart.subscalesTNNotReached | length == 1%}Subskala{% elseif barchart.subscalesTNNotReached | length > 1%}Subskalen{% endif %} wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht:</p>
                                <ul>
                                {%for question in barchart.subscalesTNNotReached %}<li>"{{question}}"</li>{% endfor %}
                                </ul>
                                <br>
                                {% endif %}
                                <script>
                                    var ctx = document.getElementById('coach_output_gbu_chart_bar_{{formid}}_{{firmaid}}_{{groupid}}_{{loop.index0}}').getContext('2d');
                                    var myChart = new Chart(ctx, {
                                        type: 'bar',
                                        plugins: [ChartDataLabels,
                                            {
                                                beforeDraw: function(chart, arg, options){
                                                    var ctx = chart.ctx;
                                                    var xAxis = chart.scales.x;
                                                    var yAxis = chart.scales.y;
                                                    ctx.fillStyle = "white";
                                                    ctx.fillRect(0, 0, chart.width, chart.height);
                                                    var chartParts = (yAxis.ticks[yAxis.ticks.length-1].value-yAxis.ticks[0].value)/0.1;
                                                    var chartPartsRatio = 1/chartParts;
                                       
                                                    {% if mode[formid] == "+-"%}
                                                        for(var i=chartParts; i>=1;i--){
                                                            var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                            if(currentVal<=2.3){
                                                                ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                            }
                                                            else if(currentVal>2.3 && currentVal<3.7){
                                                                ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                            }
                                                            else if(currentVal>=3.7){
                                                                ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                            }
                                                            ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                                        }
                                                    {% elseif mode[formid] == "-+"%}
                                                        for(var i=chartParts; i>=1;i--){
                                                            var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                            if(currentVal<=2.3){
                                                                ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                            }
                                                            else if(currentVal>2.3 && currentVal<3.7){
                                                                ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                            }
                                                            else if(currentVal>=3.7){
                                                                ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                            }
                                                            ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                                        }
                                                    {% endif %}
                                                }
                                            }
                                        ],
                                        data: {
                                            labels: {{barchart.chartlabels|json_encode|raw}},
                                            datasets: [{
                                                label: 'gesamt',
                                                data: {{barchart.gesamt|json_encode|raw}},
                                                backgroundColor: '{{barColorTotal}}',
                                                borderRadius: 3
                                            },
                                            {
                                                label: '{{barchart.labels}}',
                                                data: {{barchart.values|json_encode|raw}},
                                                backgroundColor: '{{barColorTeam}}',
                                                borderRadius: 3
                                            }]
                                        },
                                        options:{
                                            scales:{
                                                x:{
                                                    ticks:{
                                                        autoSkip: false,
                                                        font:{
                                                            size: 17
                                                        }
                                                    }
                                                },
                                                y:{
                                                    display: true,
                                                    max: 5,
                                                    min: 1,
                                                    ticks:{
                                                        font:{
                                                            size: 17
                                                        }
                                                    }
                                                }
                                            },
                                            plugins:{
                                                title:{
                                                    display: true,
                                                    text: '{{charttitles[loop.parent.loop.index0]}}',
                                                    padding: {
                                                        bottom: 15
                                                    },
                                                    font:{
                                                        size: 20
                                                    }
                                                },
                                                legend:{
                                                    labels:{
                                                        font:{
                                                            size: 17
                                                        }
                                                    },
                                                    onClick: (e) => e.stopPropagation()
                                                },
                                                tooltip:{
                                                    enabled: false
                                                },
                                                datalabels:{
                                                    anchor: 'end',
                                                    align: 'end',
                                                    font:{
                                                        size: 17
                                                    }
                                                }
                                            },

                                        }
                                    });
                                </script>
                            {% else %}
                                <div class="alert alert-info" role="alert">
                                    <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                    <p>
                                        Für alle Subskalen der Skala "{{charttitles[loop.parent.loop.index0]}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                    </p>
                                </div>
                            {% endif %}
                        {% endfor %}

                    {% endif %}
                    {% if charttype == "all" or charttype == "line" %}

                        {% for subskala, linechart in form.line %}
                            <div class="coach_output_gbu_kadmin_subscales">
                                <div class="mr-auto coach_output_gbu_chart_button">
                                    <button class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randSubscales = random()%} data-target="#gbu_chart_kadmin_subscales_{{randSubscales}}" aria-expanded="false">
                                        <p class="h6"><i class="fas fa-plus ts-accordion-plus"></i>Häufigkeiten: {{subskala}}</p>
                                    </button>
                                </div>
                                <div id="gbu_chart_kadmin_subscales_{{randSubscales}}" class="collapse mt-2 coach_output_gbu_chart_subscales coach_output_gbu_chart_accordion">
                                    {% for chart in linechart.chart %}
                                    {% if chart.mintn %}
                                    <canvas id="coach_output_gbu_chart_line_{{formid}}_{{firmaid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}" width="400" height="200"></canvas>
                                    <br>
                                    <table class="company-table-gesamt">
                                        <tbody>
                                            <tr>
                                                <td class="p-3">
                                                    <p class="mb-0"><b>Mittelwert:</b></p>
                                                </td>
                                                <td class="p-3" style="background-color: #{{chart.mean_color}}">
                                                    <b>{{chart.mean}}</b>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <br>
                                    <br>
                                    <script>
                                        var ctx = document.getElementById('coach_output_gbu_chart_line_{{formid}}_{{firmaid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}').getContext('2d');
                                        var myChart = new Chart(ctx, {
                                            type: 'line',
                                            plugins:[
                                                {
                                                    beforeDraw:function(chart, arg, options){
                                                        var ctx = chart.ctx;
                                                        ctx.save();
                                                        ctx.globalCompositeOperation = 'destination-over';
                                                        ctx.fillStyle = "white";
                                                        ctx.fillRect(0, 0, chart.width, chart.height);
                                                        ctx.restore();
                                                    }
                                                }
                                            ],
                                            data: {
                                                labels: {{chart.labels|json_encode|raw}},
                                                datasets: [{
                                                    data: {{chart.values|json_encode|raw}},
                                                    label: '{{group.groupname}}',
                                                    lineTension: 0,
                                                    fill: true
                                                }]
                                            },
                                            options: {
                                                scales:{
                                                    x:{
                                                        grid:{
                                                            display: false
                                                        },
                                                        ticks:{
                                                            font:{
                                                                size: 17
                                                            }
                                                        }
                                                    },
                                                    y:{
                                                        display: true,
                                                        beginAtZero: true,
                                                        grid:{
                                                            display: false,
                                                        },
                                                        ticks:{
                                                            display: false
                                                        }
                                                    }
                                                },
                                                elements:{
                                                    point:{
                                                        radius: 0
                                                    }
                                                },
                                                plugins:{
                                                    legend:{
                                                        display: true,
                                                        labels:{
                                                            font:{
                                                                size: 17
                                                            }
                                                        },
                                                        onClick: (e) => e.stopPropagation()
                                                    },
                                                    tooltip:{
                                                        enabled: false
                                                    },
                                                    title:{
                                                        display: true,
                                                        text: '{{chart.charttitle}}',
                                                        padding: {
                                                            bottom: 15
                                                        },
                                                        font:{
                                                            size: 20
                                                        }
                                                    }
                                                }
                                            }
                                        });
                                    </script>
                                    {% else %}
                                    <div class="alert alert-info" role="alert">
                                        <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                        <p>
                                            Für das Item "{{chart.charttitle}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                        </p>
                                    </div>
                                    {% endif %}
                                    {% endfor %}
                                </div>
                            </div>


                        {% endfor %}
                    {% endif %}
                {% endfor %}
                
                {% if showPDFDownload or showPDFDownloadBarChart or showPDFDownloadLineChart %}
                <div class="info">
                    {% if showPDFDownloadBarChart %}
                    <div class="link">
                        <i class='fas fa-external-link-alt'></i>
                        <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','{{firma.companyname}}', '{{group.groupname}}', true, false)">{{pdfDownloadTitleBarChart}}</a></p>
                    </div>
                    {% endif %}
                    {% if showPDFDownloadLineChart %}
                    <div class="link">
                        <i class='fas fa-external-link-alt'></i>
                        <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','{{firma.companyname}}', '{{group.groupname}}', false, true)">{{pdfDownloadTitleLineChart}}</a></p>
                    </div>
                    {% endif %}
                    {% if showPDFDownload %}
                    <div class="link">
                        <i class='fas fa-external-link-alt'></i>
                        <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','{{firma.companyname}}', '{{group.groupname}}', true, true)">{{pdfDownloadTitle}}</a></p>
                    </div>
                    {% endif %}
                </div>
                {% endif %}
            </div>
            {% endfor %}

        </div>
    </div>
    {% endfor %}
{% elseif isTeamleader %}
    <div class="coach_output_gbu_chart_container_teamleader" id="coach_output_gbu_chart_{{outputId}}_teamleader">
        {% for groupid, group in chartdata %}
        <div class="mr-auto coach_output_gbu_chart_button">
            <button type="button" class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randInner = random()%} data-target="#demo_{{randInner}}" aria-expanded="false">
                <p class="h5 primary-color">
                    <i class="fas fa-plus ts-accordion-plus"></i>{{group.groupname}}
                </p>
            </button>
        </div>
        <div id="demo_{{randInner}}" class="collapse mt-2 coach_output_gbu_chart_groups coach_output_gbu_chart_accordion">
            {% for formid, form in group.formdata%}
                <!-- Headline Skala -->
                <h3>{{charttitles[loop.index0]}}</h3>
                {% if charttype == "all" or charttype == "bar" %}
        
                    {% for barchart in form.bar%}
                        {% if barchart.mintn %}
                        <canvas id="coach_output_gbu_chart_bar_{{formid}}_{{groupid}}_{{loop.index0}}" width="400" height="200"></canvas>
                        <br>
                            {% if barchart.subscalesTNNotReached is not empty %}
                            <br>
                            <p>Für die folgende{% if barchart.subscalesTNNotReached | length > 1%}n{% endif %} {% if barchart.subscalesTNNotReached | length == 1%}Subskala{% elseif barchart.subscalesTNNotReached | length > 1%}Subskalen{% endif %} wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht:</p>
                            <ul>
                            {%for question in barchart.subscalesTNNotReached %}<li>"{{question}}"</li>{% endfor %}
                            </ul>
                        <br>
                        {% endif %}
                        <script>
                        var ctx = document.getElementById('coach_output_gbu_chart_bar_{{formid}}_{{groupid}}_{{loop.index0}}').getContext('2d');
                        var myChart = new Chart(ctx, {
                            type: 'bar',
                            plugins: [ChartDataLabels,
                                {
                                   beforeDraw: function(chart, arg, options){
                                       var ctx = chart.ctx;
                                       var xAxis = chart.scales.x;
                                       var yAxis = chart.scales.y;
                                       ctx.fillStyle = "white";
                                       ctx.fillRect(0, 0, chart.width, chart.height);
                                       var chartParts = (yAxis.ticks[yAxis.ticks.length-1].value-yAxis.ticks[0].value)/0.1;
                                       var chartPartsRatio = 1/chartParts;
                                       
                                       {% if mode[formid] == "+-"%}
                                            for(var i=chartParts; i>=1;i--){
                                                var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                if(currentVal<=2.3){
                                                    ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                }
                                                else if(currentVal>2.3 && currentVal<3.7){
                                                    ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                }
                                                else if(currentVal>=3.7){
                                                    ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                }
                                                ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                            }
                                       {% elseif mode[formid] == "-+"%}
                                            for(var i=chartParts; i>=1;i--){
                                                var currentVal = yAxis.ticks[yAxis.ticks.length-1].value-i*0.1;
                                                if(currentVal<=2.3){
                                                    ctx.fillStyle = "rgba(244,133,142,{{alpha}})";
                                                }
                                                else if(currentVal>2.3 && currentVal<3.7){
                                                    ctx.fillStyle = "rgba(254,216,143,{{alpha}})";
                                                }
                                                else if(currentVal>=3.7){
                                                    ctx.fillStyle = "rgba(191,226,202,{{alpha}})";
                                                }
                                                ctx.fillRect(xAxis.left,yAxis.top + (i-1)*(yAxis.height*chartPartsRatio),xAxis.width, yAxis.height*chartPartsRatio);
                                            }
                                       {% endif %}
                                   }
                                }
                            ],
                            data: {
                                labels: {{barchart.chartlabels|json_encode|raw}},
                                datasets: [
                                {
                                    label: '{{barchart.labels}}',
                                    data: {{barchart.values|json_encode|raw}},
                                    backgroundColor: '{{barColorTeam}}',
                                    borderRadius: 3
                                }]
                            },
                            options:{
                                scales:{
                                    x:{
                                        ticks:{
                                            autoSkip: false,
                                            font:{
                                                size: 17
                                            }
                                        }
                                    },
                                    y:{
                                        display: true,
                                        max: 5,
                                        min: 1,
                                        ticks:{
                                            font:{
                                                size: 17
                                            }
                                        }
                                    }
                                },
                                plugins:{
                                    title:{
                                        display: true,
                                        text: '{{charttitles[loop.parent.loop.index0]}}',
                                        padding: {
                                            bottom: 15
                                        },
                                        font:{
                                            size: 20
                                        }
                                    },
                                    legend:{
                                        labels:{
                                            font:{
                                                size: 17
                                            }
                                        },
                                        onClick: (e) => e.stopPropagation()
                                    },
                                    tooltip:{
                                        enabled: false
                                    },
                                    datalabels:{
                                        anchor: 'end',
                                        align: 'end',
                                        font:{
                                            size: 17
                                        }
                                    }
                                },

                            }
                        });
                        </script>
                        {% else %}
                            <div class="alert alert-info" role="alert">
                                <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                <p>
                                    Für alle Subskalen der Skala "{{charttitles[loop.parent.loop.index0]}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                </p>
                            </div>
                        {% endif %}
                    {% endfor %}
                {% endif %}
                {% if charttype == "all" or charttype == "line" %}
                    {% for subskala, linechart in form.line %}
                    <div class="coach_output_gbu_teamleader_subscales">
                        <div class="mr-auto coach_output_gbu_chart_button">
                            <button class="btn btn-link ts-list-button px-0" data-toggle="collapse" {%set randSubscales = random()%} data-target="#gbu_chart_teamleader_subscales_{{randSubscales}}" aria-expanded="false">
                                <p class="h6"><i class="fas fa-plus ts-accordion-plus"></i>Häufigkeiten: {{subskala}}</p>
                            </button>
                        </div>
                        <div id="gbu_chart_teamleader_subscales_{{randSubscales}}" class="collapse mt-2 coach_output_gbu_chart_subscales coach_output_gbu_chart_accordion">
                            {% for chart in linechart.chart %}
                            {% if chart.mintn %}
                            <canvas id="coach_output_gbu_chart_line_{{formid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}" width="400" height="200"></canvas>
                            <br>
                            <table class="company-table-gesamt">
                                <tbody>
                                    <tr>
                                        <td class="p-3">
                                            <p class="mb-0"><b>Mittelwert:</b></p>
                                        </td>
                                        <td class="p-3" style="background-color: #{{chart.mean_color}}">
                                            <b>{{chart.mean}}</b>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <br>
                            <br>
                            <script>
                            var ctx = document.getElementById('coach_output_gbu_chart_line_{{formid}}_{{groupid}}_{{loop.parent.loop.index0}}_{{loop.index0}}').getContext('2d');
                            var myChart = new Chart(ctx, {
                                type: 'line',
                                plugins:[
                                    {
                                        beforeDraw:function(chart, arg, options){
                                            var ctx = chart.ctx;
                                            ctx.save();
                                            ctx.globalCompositeOperation = 'destination-over';
                                            ctx.fillStyle = "white";
                                            ctx.fillRect(0, 0, chart.width, chart.height);
                                            ctx.restore();
                                        }
                                    }
                                ],
                                data: {
                                    labels: {{chart.labels|json_encode|raw}},
                                    datasets: [{
                                        data: {{chart.values|json_encode|raw}},
                                        label: '{{group.groupname}}',
                                        lineTension: 0,
                                        fill: true
                                    }]
                                },
                                options: {
                                    scales:{
                                        x:{
                                            grid:{
                                                display: false
                                            },
                                            ticks:{
                                                font:{
                                                    size: 17
                                                }
                                            }
                                        },
                                        y:{
                                            display: true,
                                            beginAtZero: true,
                                            grid:{
                                                display: false,
                                            },
                                            ticks:{
                                                display: false
                                            }
                                        }
                                    },
                                    elements:{
                                        point:{
                                            radius: 0
                                        }
                                    },
                                    plugins:{
                                        legend:{
                                            display: true,
                                            labels:{
                                                font:{
                                                    size: 17
                                                }
                                            },
                                            onClick: (e) => e.stopPropagation()
                                        },
                                        tooltip:{
                                            enabled: false
                                        },
                                        title:{
                                            display: true,
                                            text: '{{chart.charttitle}}',
                                            padding: {
                                                bottom: 15
                                            },
                                            font:{
                                                size: 20
                                            }
                                        }
                                    }
                                }
                            });
                            </script>
                            {% else %}
                            <div class="alert alert-info" role="alert">
                                <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                                <p>
                                    Für das Item "{{chart.charttitle}}" wurde der Mindestwert von {{MINTEILNEHMER}} Teilnehmenden nicht erreicht.
                                </p>
                            </div>
                            {% endif %}
                        {% endfor %}
                        </div>
                    </div>


                    {% endfor %}
                {% endif %}

            {% endfor %}
        
            {% if showPDFDownload or showPDFDownloadBarChart or showPDFDownloadLineChart %}
            <div class="info">
                {% if showPDFDownloadBarChart %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', true, false)">{{pdfDownloadTitleBarChart}}</a></p>
                </div>
                {% endif %}
                {% if showPDFDownloadLineChart %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', false, true)">{{pdfDownloadTitleLineChart}}</a></p>
                </div>
                {% endif %}
                {% if showPDFDownload %}
                <div class="link">
                    <i class='fas fa-external-link-alt'></i>
                    <p><a id="" href="javascript:startPrintGBUPDF('demo_{{randInner}}','', '{{group.groupname}}', true, true)">{{pdfDownloadTitle}}</a></p>
                </div>
                {% endif %}
            </div>
            {% endif %}
        </div>
        {% endfor %}
    </div>
{% else %}
    <div class="alert alert-info" role="alert">
        <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
        <p>
            Es wird nichts angezeigt, da Sie nicht die notwendigen Berechtigungen für diesen Inhalt haben.
        </p>
    </div>
{% endif %}
</div>

<script>
    function startPrintGBUPDF(divid, company, group, printBarChart, printLineChart){
        if(jQuery('#'+divid).find('div.coach_output_gbu_chart_accordion').length){
            jQuery('#'+divid).find('div.coach_output_gbu_chart_accordion').collapse();
            var tOut = setTimeout(function(){
                generateGBUPDF(divid, company, group, printBarChart, printLineChart);
            }, 2000);
        }
        else{
            generateGBUPDF(divid, company, group, printBarChart, printLineChart);
        }
    }

    function generateGBUPDF(divid, company, group, printBarChart, printLineChart){
        // Angaben zur PDF
        var pdfOrientation = "p";
        var pdfFormat = "a4";
        // Font
        var pdfFont = "helvetica";
        var currentFontSize = 12;
        var currentFontStyle = "normal";
        // Seitenränder (Werte jeweils in mm)
        var pdfMarginTop = 25;
        var pdfMarginLeft = 25;
        var pdfMarginRight = 25;
        var pdfMarginBottom = 20;
        // Erstellen der PDF-Instanz
        var doc = new jspdf.jsPDF({orientation: pdfOrientation, format: pdfFormat});
        // Höhe/Breite/Mitte der PDF (Werte jeweils in mm)
        var maxHeight = doc.internal.pageSize.height;
        var maxWidth = doc.internal.pageSize.width;
        var pdfCenter = maxWidth/2;
        // Seitenzahl
        doc.page = 1;
        var pageNumberFontSize = 11;
        var pageNumberFontStyle = "normal";
        // Schreiben der Seitenzahl auf der ersten Seite
        doc = gbuPDFWritePageNumber(doc, pdfFont, currentFontSize, currentFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginBottom, maxHeight);

        // Maximal erlaubte Breite für Inhtalt in der PDF (Wert in mm)
        var maxContentWidth = maxWidth - pdfMarginLeft - pdfMarginRight;
        // Aktuelle Position in y-Richtung im Dokument
        var currentHeightPosition = pdfMarginTop;

        // Schreibe Firmennamen und Gruppennamen als Überschrift ins Dokument
        var docHeadline = "";
        if(company != ""){
            docHeadline = company + " - " + group;
        }
        else{
            docHeadline += group;
        }
        
        // Schriftgröße der Überschrift für das Dokument festlegen
        var docHeadlineFontSize = 22;
        // Zwischenspeichern der aktuellen Schriftgröße
        var currentFontSize = doc.getFontSize();
        doc.setFontSize(docHeadlineFontSize);

        docHeadline = gbuPDFReplaceSpecialCharacters(docHeadline);
        var docHeadlineArray = doc.splitTextToSize(docHeadline, maxContentWidth);
        for(var docH=0; docH < docHeadlineArray.length; docH++){
            // Zeile passt nicht mehr auf Seite
            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                var docFontSize = doc.getFontSize();
                var docFontStyle = "normal";
                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                doc = result[0]; 
                currentHeightPosition = result[1];
            }
            var writeResult = gbuPDFWriteContent(doc, docHeadlineArray[docH], pdfMarginLeft, currentHeightPosition);
            doc = writeResult[0];
            currentHeightPosition = writeResult[1];
        }

        // Zurücksetzen der Schriftgröße
        doc.setFontSize(currentFontSize);
        currentHeightPosition += 3;

        var divContainer = jQuery('#'+divid).contents();
        

        for(var divCons=0; divCons < divContainer.length; divCons++){

            if(jQuery(divContainer[divCons]).is("h3")){
                currentHeightPosition += 3;
                var headlineText = jQuery(divContainer[divCons]).text();
                // Abrufen der Schriftfarbe und -größe für die Überschrift
                var headlineFontSize = 18;
                // Zwischenspeichern der aktuellen Schriftfarbe und -größe
                var currentFontSize = doc.getFontSize();
                // Schriftfarbe für Überschrift setzen
                doc.setFontSize(headlineFontSize);

                // Ersetze Sonderzeichen in Überschrift
                headlineText = gbuPDFReplaceSpecialCharacters(headlineText);
                var headLineTextArray = doc.splitTextToSize(headlineText, maxContentWidth);
                for(var i=0; i< headLineTextArray.length; i++){
                    // Zeile passt nicht mehr auf Seite
                    if(currentHeightPosition + pdfMarginBottom > maxHeight){
                        var docFontSize = doc.getFontSize();
                        var docFontStyle = "normal";
                        var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                        doc = result[0]; 
                        currentHeightPosition = result[1];
                    }
                    var writeResult = gbuPDFWriteContent(doc, headLineTextArray[i], pdfMarginLeft, currentHeightPosition);
                    doc = writeResult[0];
                    currentHeightPosition = writeResult[1];
                }

                // Zurücksetzen der Schriftfarbe und -größe
                doc.setFontSize(currentFontSize);
            }
            else if(jQuery(divContainer[divCons]).is("p") && printBarChart){
                var contentText = jQuery(divContainer[divCons]).text();
                contentText = gbuPDFReplaceSpecialCharacters(contentText);
                var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                for(var cText=0; cText < contentTextArray.length; cText++){
                    // Zeile passt nicht mehr auf Seite
                    if(currentHeightPosition + pdfMarginBottom > maxHeight){
                        var docFontSize = doc.getFontSize();
                        var docFontStyle = "normal";
                        var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                        doc = result[0];
                        currentHeightPosition = result[1];
                    }
                    var writeResult = gbuPDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                    doc = writeResult[0];
                    currentHeightPosition = writeResult[1];
                }
                currentHeightPosition += 1.5;
            }
            else if(jQuery(divContainer[divCons]).is("br") && printBarChart){
                // Zeile passt nicht mehr auf Seite
                if(currentHeightPosition + pdfMarginBottom > maxHeight){
                    var docFontSize = doc.getFontSize();
                    var docFontStyle = "normal";
                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                    doc = result[0]; 
                    currentHeightPosition = result[1];
                }
                var writeResult = gbuPDFWriteContent(doc, "", pdfMarginLeft, currentHeightPosition);
                doc = writeResult[0];
                currentHeightPosition = writeResult[1];
            }
            else if(jQuery(divContainer[divCons]).is("ul") && printBarChart){
                var bulletpoint = "-";
                var listItems = jQuery(divContainer[divCons]).contents();
                var bulletpointLength = (doc.getStringUnitWidth(bulletpoint)*doc.getFontSize())/(72/25.6);

                for(var listItemIndex = 0; listItemIndex < listItems.length; listItemIndex++){

                    if(jQuery(listItems[listItemIndex]).is("li")){
                        var listItemContent = jQuery(listItems[listItemIndex]).text();
                        listItemContent = gbuPDFReplaceSpecialCharacters(listItemContent);
                        var listItemContentArray = doc.splitTextToSize(listItemContent, maxContentWidth-bulletpointLength);
                        for(var listItemContentIndex = 0; listItemContentIndex < listItemContentArray.length; listItemContentIndex++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0]; 
                                currentHeightPosition = result[1];
                            }
                            // Zeichne Bulletpoint
                            if(listItemContentIndex == 0){
                                var writeResult = gbuPDFWriteContent(doc, bulletpoint, pdfMarginLeft, currentHeightPosition);
                                doc = writeResult[0];
                            }
                            var writeResult = gbuPDFWriteContent(doc, listItemContentArray[listItemContentIndex], pdfMarginLeft+bulletpointLength, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                    }
                }
            }
            else if(jQuery(divContainer[divCons]).is("canvas") && printBarChart){
                var canvasWidth = maxContentWidth;
                var canvasHeight = maxContentWidth/2;

                // Das Bild passt nicht auf die aktuelle Seite -> Lege eine neue Seite an
                if(canvasHeight > maxHeight - pdfMarginBottom - currentHeightPosition){
                    var docFontSize = doc.getFontSize();
                    var docFontStyle = "normal";
                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                    doc = result[0]; 
                    currentHeightPosition = result[1];
                }

                var canvasSource = divContainer[divCons].toDataURL("image/jpeg");
                doc.addImage(canvasSource, 'JPEG', pdfMarginLeft, currentHeightPosition, canvasWidth, canvasHeight, '', 'FAST');
                // Füge einen Abstand unterhalb des Bildes hinzu
                currentHeightPosition+= canvasHeight + 2*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
            }
            else if(jQuery(divContainer[divCons]).is("div.alert") && printBarChart){
                var alertContent = jQuery(divContainer[divCons]).contents();
                for(var alertDivCons = 0; alertDivCons < alertContent.length; alertDivCons++){
                    if(jQuery(alertContent[alertDivCons]).is("h5")){
                        currentHeightPosition += 3;
                        var headlineText = jQuery(alertContent[alertDivCons]).text();
                        headlineText = headlineText.trim();
                        var headlineFontSize = 14;
                        // Zwischenspeichern der aktuellen Schriftgröße
                        var currentFontSize = doc.getFontSize();
                        // Schriftgröße für Überschrift setzen
                        doc.setFontSize(headlineFontSize);

                        // Ersetze Sonderzeichen in Überschrift
                        headlineText = gbuPDFReplaceSpecialCharacters(headlineText);
                        var headLineTextArray = doc.splitTextToSize(headlineText, maxContentWidth);
                        for(var i=0; i< headLineTextArray.length; i++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0]; 
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuPDFWriteContent(doc, headLineTextArray[i], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }

                        // Zurücksetzen der Schriftgröße
                        doc.setFontSize(currentFontSize);
                    }
                    else if(jQuery(alertContent[alertDivCons]).is("p")){
                        var contentText = jQuery(alertContent[alertDivCons]).text();
                        contentText = contentText.trim();
                        contentText = gbuPDFReplaceSpecialCharacters(contentText);
                        var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                        for(var cText=0; cText < contentTextArray.length; cText++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0];
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuPDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                    }
                }
                currentHeightPosition += 4;
            }
            else if(jQuery(divContainer[divCons]).is("div.coach_output_gbu_boss_subscales") && printLineChart){
                var bossDivSubscalesContent = jQuery(divContainer[divCons]).contents();
                for(var bossDivSubscalesCons = 0; bossDivSubscalesCons < bossDivSubscalesContent.length; bossDivSubscalesCons++){
                    if(jQuery(bossDivSubscalesContent[bossDivSubscalesCons]).is("div.coach_output_gbu_chart_button")){
                        var buttonText = jQuery(bossDivSubscalesContent[bossDivSubscalesCons]).find("button").text();
                        var headlineTextColor = jQuery(bossDivSubscalesContent[bossDivSubscalesCons]).find("button p").css("color");
                        var headlineFontSize = 16;
                        buttonText = buttonText.trim();
                        // Zwischenspeichern der aktuellen Schriftfarbe und -größe
                        var currentTextColor = doc.getTextColor();
                        var currentFontSize =  doc.getFontSize();
                        // Schriftfarbe für Überschrift setzen
                        doc.setTextColor(headlineTextColor);
                        doc.setFontSize(headlineFontSize);
                        buttonText = gbuPDFReplaceSpecialCharacters(buttonText);
                        var buttonTextArray = doc.splitTextToSize(buttonText, maxContentWidth);
                        for(var buttonIndex = 0; buttonIndex < buttonTextArray.length; buttonIndex++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0]; 
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuPDFWriteContent(doc, buttonTextArray[buttonIndex], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                        // Zurücksetzen der Schriftfarbe und -größe
                        doc.setTextColor(currentTextColor);
                        doc.setFontSize(currentFontSize);
                    }
                    else if(jQuery(bossDivSubscalesContent[bossDivSubscalesCons]).is("div.coach_output_gbu_chart_subscales")){
                        var bossSubscalesContent = jQuery(bossDivSubscalesContent[bossDivSubscalesCons]).contents();
                        for(var bossSubscalesCons = 0; bossSubscalesCons < bossSubscalesContent.length; bossSubscalesCons++){
                            if(jQuery(bossSubscalesContent[bossSubscalesCons]).is("canvas")){
                                var canvasWidth = maxContentWidth;
                                var canvasHeight = maxContentWidth/2;

                                // Das Bild passt nicht auf die aktuelle Seite -> Lege eine neue Seite an
                                if(canvasHeight > maxHeight - pdfMarginBottom - currentHeightPosition){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }

                                var canvasSource = bossSubscalesContent[bossSubscalesCons].toDataURL("image/jpeg");
                                doc.addImage(canvasSource, 'JPEG', pdfMarginLeft, currentHeightPosition, canvasWidth, canvasHeight, '', 'FAST');
                                // Füge einen Abstand unterhalb des Bildes hinzu
                                currentHeightPosition+= canvasHeight + 2*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                            }
                            else if(jQuery(bossSubscalesContent[bossSubscalesCons]).is("br")){
                                // Zeile passt nicht mehr auf Seite
                                if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }
                                var writeResult = gbuPDFWriteContent(doc, "", pdfMarginLeft, currentHeightPosition);
                                doc = writeResult[0];
                                currentHeightPosition = writeResult[1];
                            }
                            else if(jQuery(bossSubscalesContent[bossSubscalesCons]).is("table.company-table-gesamt")){
                                var tableContent = jQuery(bossSubscalesContent[bossSubscalesCons]).contents();
                                for(var tableCons = 0; tableCons < tableContent.length; tableCons++){

                                    if(jQuery(tableContent[tableCons]).is("tbody")){
                                        var tdElements = jQuery(tableContent[tableCons]).find("td");
                                        // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginX = 5;
                                        // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                        // Zusätzlicher Abstand nach Zeichnen des Rahmens
                                        var offsetYDir =  3;
                        
                                        for(var tdIndex = 0; tdIndex < tdElements.length; tdIndex++){
                                            // Tabelle passt nicht mehr auf die aktuelle Seite
                                            doc.setFont(pdfFont, "bold");
                                            if(currentHeightPosition + 2*fieldMarginY + (doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778) > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                                doc.setFont(pdfFont, "bold");
                                            }

                                            var tdText = jQuery(tdElements[tdIndex]).find("b").text();
                                            var tdTextDim = doc.getTextDimensions(tdText);
                                            if(tdIndex == 0){
                                                doc.setFillColor(255,255,255);
                                                doc.rect(pdfMarginLeft, currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.text(tdText, pdfMarginLeft+fieldMarginX, currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                            else{
                                                var tdColor = jQuery(tdElements[tdIndex]).css('background-color');
                                                doc.setFillColor(tdColor);
                                                var previousTdElementDim = doc.getTextDimensions(jQuery(tdElements[tdIndex-1]).find("b").text());
                                                doc.rect(pdfMarginLeft+2*fieldMarginX+previousTdElementDim['w'], currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.setFillColor(255,255,255);
                                                doc.text(tdText, pdfMarginLeft+3*fieldMarginX+previousTdElementDim['w'], currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                        }
                                        currentHeightPosition += 20;
                                        doc.setFont(pdfFont, "normal");
                                    }
                                }
                            }
                            else if(jQuery(bossSubscalesContent[bossSubscalesCons]).is("div.alert")){
                                var alertContent = jQuery(bossSubscalesContent[bossSubscalesCons]).contents();
                                for(var alertDivCons = 0; alertDivCons < alertContent.length; alertDivCons++){
                                    if(jQuery(alertContent[alertDivCons]).is("h5")){
                                        currentHeightPosition += 3;
                                        var headlineText = jQuery(alertContent[alertDivCons]).text();
                                        headlineText = headlineText.trim();
                                        var headlineFontSize = 14;
                                        // Zwischenspeichern der aktuellen Schriftgröße
                                        var currentFontSize = doc.getFontSize();
                                        // Schriftgröße für Überschrift setzen
                                        doc.setFontSize(headlineFontSize);

                                        // Ersetze Sonderzeichen in Überschrift
                                        headlineText = gbuPDFReplaceSpecialCharacters(headlineText);
                                        var headLineTextArray = doc.splitTextToSize(headlineText, maxContentWidth);
                                        for(var i=0; i< headLineTextArray.length; i++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0]; 
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, headLineTextArray[i], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }

                                        // Zurücksetzen der Schriftgröße
                                        doc.setFontSize(currentFontSize);
                                    }
                                    else if(jQuery(alertContent[alertDivCons]).is("p")){
                                        var contentText = jQuery(alertContent[alertDivCons]).text();
                                        contentText = contentText.trim();
                                        contentText = gbuPDFReplaceSpecialCharacters(contentText);
                                        var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                                        for(var cText=0; cText < contentTextArray.length; cText++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }
                                    }
                                }
                                currentHeightPosition += 4;
                            }
                        }
                    }
                }
            }
            else if(jQuery(divContainer[divCons]).is("div.coach_output_gbu_kadmin_subscales") && printLineChart){
                var kadminDivSubscalesContent = jQuery(divContainer[divCons]).contents();
                for(var kadminDivSubscalesCons = 0; kadminDivSubscalesCons < kadminDivSubscalesContent.length; kadminDivSubscalesCons++){
                    if(jQuery(kadminDivSubscalesContent[kadminDivSubscalesCons]).is("div.coach_output_gbu_chart_button")){
                        var buttonText = jQuery(kadminDivSubscalesContent[kadminDivSubscalesCons]).find("button").text();
                        var headlineTextColor = jQuery(kadminDivSubscalesContent[kadminDivSubscalesCons]).find("button p").css("color");
                        var headlineFontSize = 16;
                        buttonText = buttonText.trim();
                        // Zwischenspeichern der aktuellen Schriftfarbe und -größe
                        var currentTextColor = doc.getTextColor();
                        var currentFontSize =  doc.getFontSize();
                        // Schriftfarbe für Überschrift setzen
                        doc.setTextColor(headlineTextColor);
                        doc.setFontSize(headlineFontSize);
                        buttonText = gbuPDFReplaceSpecialCharacters(buttonText);
                        var buttonTextArray = doc.splitTextToSize(buttonText, maxContentWidth);
                        for(var buttonIndex = 0; buttonIndex < buttonTextArray.length; buttonIndex++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0]; 
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuPDFWriteContent(doc, buttonTextArray[buttonIndex], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                        // Zurücksetzen der Schriftfarbe und -größe
                        doc.setTextColor(currentTextColor);
                        doc.setFontSize(currentFontSize);
                    }
                    else if(jQuery(kadminDivSubscalesContent[kadminDivSubscalesCons]).is("div.coach_output_gbu_chart_subscales")){
                        var kadminSubscalesContent = jQuery(kadminDivSubscalesContent[kadminDivSubscalesCons]).contents();
                        for(var kadminSubscalesCons = 0; kadminSubscalesCons < kadminSubscalesContent.length; kadminSubscalesCons++){
                            if(jQuery(kadminSubscalesContent[kadminSubscalesCons]).is("canvas")){
                                var canvasWidth = maxContentWidth;
                                var canvasHeight = maxContentWidth/2;

                                // Das Bild passt nicht auf die aktuelle Seite -> Lege eine neue Seite an
                                if(canvasHeight > maxHeight - pdfMarginBottom - currentHeightPosition){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }

                                var canvasSource = kadminSubscalesContent[kadminSubscalesCons].toDataURL("image/jpeg");
                                doc.addImage(canvasSource, 'JPEG', pdfMarginLeft, currentHeightPosition, canvasWidth, canvasHeight, '', 'FAST');
                                // Füge einen Abstand unterhalb des Bildes hinzu
                                currentHeightPosition+= canvasHeight + 2*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                            }
                            else if(jQuery(kadminSubscalesContent[kadminSubscalesCons]).is("br")){
                                // Zeile passt nicht mehr auf Seite
                                if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }
                                var writeResult = gbuPDFWriteContent(doc, "", pdfMarginLeft, currentHeightPosition);
                                doc = writeResult[0];
                                currentHeightPosition = writeResult[1];
                            }
                            else if(jQuery(kadminSubscalesContent[kadminSubscalesCons]).is("table.company-table-gesamt")){
                                var tableContent = jQuery(kadminSubscalesContent[kadminSubscalesCons]).contents();
                                for(var tableCons = 0; tableCons < tableContent.length; tableCons++){

                                    if(jQuery(tableContent[tableCons]).is("tbody")){
                                        var tdElements = jQuery(tableContent[tableCons]).find("td");
                                        // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginX = 5;
                                        // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                        // Zusätzlicher Abstand nach Zeichnen des Rahmens
                                        var offsetYDir =  3;
                        
                                        for(var tdIndex = 0; tdIndex < tdElements.length; tdIndex++){
                                            // Tabelle passt nicht mehr auf die aktuelle Seite
                                            doc.setFont(pdfFont, "bold");
                                            if(currentHeightPosition + 2*fieldMarginY + (doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778) > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                                doc.setFont(pdfFont, "bold");
                                            }

                                            var tdText = jQuery(tdElements[tdIndex]).find("b").text();
                                            var tdTextDim = doc.getTextDimensions(tdText);
                                            if(tdIndex == 0){
                                                doc.setFillColor(255,255,255);
                                                doc.rect(pdfMarginLeft, currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.text(tdText, pdfMarginLeft+fieldMarginX, currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                            else{
                                                var tdColor = jQuery(tdElements[tdIndex]).css('background-color');
                                                doc.setFillColor(tdColor);
                                                var previousTdElementDim = doc.getTextDimensions(jQuery(tdElements[tdIndex-1]).find("b").text());
                                                doc.rect(pdfMarginLeft+2*fieldMarginX+previousTdElementDim['w'], currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.setFillColor(255,255,255);
                                                doc.text(tdText, pdfMarginLeft+3*fieldMarginX+previousTdElementDim['w'], currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                        }
                                        currentHeightPosition += 20;
                                        doc.setFont(pdfFont, "normal");
                                    }
                                }
                            }
                            else if(jQuery(kadminSubscalesContent[kadminSubscalesCons]).is("div.alert")){
                                var alertContent = jQuery(kadminSubscalesContent[kadminSubscalesCons]).contents();
                                for(var alertDivCons = 0; alertDivCons < alertContent.length; alertDivCons++){
                                    if(jQuery(alertContent[alertDivCons]).is("h5")){
                                        currentHeightPosition += 3;
                                        var headlineText = jQuery(alertContent[alertDivCons]).text();
                                        headlineText = headlineText.trim();
                                        var headlineFontSize = 14;
                                        // Zwischenspeichern der aktuellen Schriftgröße
                                        var currentFontSize = doc.getFontSize();
                                        // Schriftgröße für Überschrift setzen
                                        doc.setFontSize(headlineFontSize);

                                        // Ersetze Sonderzeichen in Überschrift
                                        headlineText = gbuPDFReplaceSpecialCharacters(headlineText);
                                        var headLineTextArray = doc.splitTextToSize(headlineText, maxContentWidth);
                                        for(var i=0; i< headLineTextArray.length; i++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0]; 
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, headLineTextArray[i], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }

                                        // Zurücksetzen der Schriftgröße
                                        doc.setFontSize(currentFontSize);
                                    }
                                    else if(jQuery(alertContent[alertDivCons]).is("p")){
                                        var contentText = jQuery(alertContent[alertDivCons]).text();
                                        contentText = contentText.trim();
                                        contentText = gbuPDFReplaceSpecialCharacters(contentText);
                                        var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                                        for(var cText=0; cText < contentTextArray.length; cText++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }
                                    }
                                }
                                currentHeightPosition += 4;
                            }
                        }
                    }
                }
            }
            else if(jQuery(divContainer[divCons]).is("div.coach_output_gbu_teamleader_subscales") && printLineChart){
                var teamleaderDivSubscalesContent = jQuery(divContainer[divCons]).contents();
                for(var teamleaderDivSubscalesCons = 0; teamleaderDivSubscalesCons < teamleaderDivSubscalesContent.length; teamleaderDivSubscalesCons++){
                    if(jQuery(teamleaderDivSubscalesContent[teamleaderDivSubscalesCons]).is("div.coach_output_gbu_chart_button")){
                        var buttonText = jQuery(teamleaderDivSubscalesContent[teamleaderDivSubscalesCons]).find("button").text();
                        var headlineTextColor = jQuery(teamleaderDivSubscalesContent[teamleaderDivSubscalesCons]).find("button p").css("color");
                        var headlineFontSize = 16;
                        buttonText = buttonText.trim();
                        // Zwischenspeichern der aktuellen Schriftfarbe und -größe
                        var currentTextColor = doc.getTextColor();
                        var currentFontSize =  doc.getFontSize();
                        // Schriftfarbe für Überschrift setzen
                        doc.setTextColor(headlineTextColor);
                        doc.setFontSize(headlineFontSize);
                        buttonText = gbuPDFReplaceSpecialCharacters(buttonText);
                        var buttonTextArray = doc.splitTextToSize(buttonText, maxContentWidth);
                        for(var buttonIndex = 0; buttonIndex < buttonTextArray.length; buttonIndex++){
                            // Zeile passt nicht mehr auf Seite
                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                var docFontSize = doc.getFontSize();
                                var docFontStyle = "normal";
                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                doc = result[0]; 
                                currentHeightPosition = result[1];
                            }
                            var writeResult = gbuPDFWriteContent(doc, buttonTextArray[buttonIndex], pdfMarginLeft, currentHeightPosition);
                            doc = writeResult[0];
                            currentHeightPosition = writeResult[1];
                        }
                        // Zurücksetzen der Schriftfarbe und -größe
                        doc.setTextColor(currentTextColor);
                        doc.setFontSize(currentFontSize);
                    }
                    else if(jQuery(teamleaderDivSubscalesContent[teamleaderDivSubscalesCons]).is("div.coach_output_gbu_chart_subscales")){
                        var teamleaderSubscalesContent = jQuery(teamleaderDivSubscalesContent[teamleaderDivSubscalesCons]).contents();
                        for(var teamleaderSubscalesCons = 0; teamleaderSubscalesCons < teamleaderSubscalesContent.length; teamleaderSubscalesCons++){
                            if(jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).is("canvas")){
                                var canvasWidth = maxContentWidth;
                                var canvasHeight = maxContentWidth/2;

                                // Das Bild passt nicht auf die aktuelle Seite -> Lege eine neue Seite an
                                if(canvasHeight > maxHeight - pdfMarginBottom - currentHeightPosition){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }

                                var canvasSource = teamleaderSubscalesContent[teamleaderSubscalesCons].toDataURL("image/jpeg");
                                doc.addImage(canvasSource, 'JPEG', pdfMarginLeft, currentHeightPosition, canvasWidth, canvasHeight, '', 'FAST');
                                // Füge einen Abstand unterhalb des Bildes hinzu
                                currentHeightPosition+= canvasHeight + 2*(doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778);
                            }
                            else if(jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).is("br")){
                                // Zeile passt nicht mehr auf Seite
                                if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                    var docFontSize = doc.getFontSize();
                                    var docFontStyle = "normal";
                                    var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                    doc = result[0]; 
                                    currentHeightPosition = result[1];
                                }
                                var writeResult = gbuPDFWriteContent(doc, "", pdfMarginLeft, currentHeightPosition);
                                doc = writeResult[0];
                                currentHeightPosition = writeResult[1];
                            }
                            else if(jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).is("table.company-table-gesamt")){
                                var tableContent = jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).contents();
                                for(var tableCons = 0; tableCons < tableContent.length; tableCons++){

                                    if(jQuery(tableContent[tableCons]).is("tbody")){
                                        var tdElements = jQuery(tableContent[tableCons]).find("td");
                                        // Abstand (in x-Richtung) zwischen (linken/rechten) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginX = 5;
                                        // Abstand (in y-Richtung) zwischen (oberen/unteren) 'Rand' des Feldes zum Inhalt des Feldes
                                        var fieldMarginY = doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
                                        // Zusätzlicher Abstand nach Zeichnen des Rahmens
                                        var offsetYDir =  3;
                        
                                        for(var tdIndex = 0; tdIndex < tdElements.length; tdIndex++){
                                            // Tabelle passt nicht mehr auf die aktuelle Seite
                                            doc.setFont(pdfFont, "bold");
                                            if(currentHeightPosition + 2*fieldMarginY + (doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778) > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                                doc.setFont(pdfFont, "bold");
                                            }

                                            var tdText = jQuery(tdElements[tdIndex]).find("b").text();
                                            var tdTextDim = doc.getTextDimensions(tdText);
                                            if(tdIndex == 0){
                                                doc.setFillColor(255,255,255);
                                                doc.rect(pdfMarginLeft, currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.text(tdText, pdfMarginLeft+fieldMarginX, currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                            else{
                                                var tdColor = jQuery(tdElements[tdIndex]).css('background-color');
                                                doc.setFillColor(tdColor);
                                                var previousTdElementDim = doc.getTextDimensions(jQuery(tdElements[tdIndex-1]).find("b").text());
                                                doc.rect(pdfMarginLeft+2*fieldMarginX+previousTdElementDim['w'], currentHeightPosition, 2*fieldMarginX+tdTextDim['w'], 2*fieldMarginY+doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778, 'DF');
                                                doc.setFillColor(255,255,255);
                                                doc.text(tdText, pdfMarginLeft+3*fieldMarginX+previousTdElementDim['w'], currentHeightPosition+fieldMarginY+offsetYDir);
                                            }
                                        }
                                        currentHeightPosition += 20;
                                        doc.setFont(pdfFont, "normal");
                                    }
                                }
                            }
                            else if(jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).is("div.alert")){
                                var alertContent = jQuery(teamleaderSubscalesContent[teamleaderSubscalesCons]).contents();
                                for(var alertDivCons = 0; alertDivCons < alertContent.length; alertDivCons++){
                                    if(jQuery(alertContent[alertDivCons]).is("h5")){
                                        currentHeightPosition += 3;
                                        var headlineText = jQuery(alertContent[alertDivCons]).text();
                                        headlineText = headlineText.trim();
                                        var headlineFontSize = 14;
                                        // Zwischenspeichern der aktuellen Schriftgröße
                                        var currentFontSize = doc.getFontSize();
                                        // Schriftgröße für Überschrift setzen
                                        doc.setFontSize(headlineFontSize);

                                        // Ersetze Sonderzeichen in Überschrift
                                        headlineText = gbuPDFReplaceSpecialCharacters(headlineText);
                                        var headLineTextArray = doc.splitTextToSize(headlineText, maxContentWidth);
                                        for(var i=0; i< headLineTextArray.length; i++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0]; 
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, headLineTextArray[i], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }

                                        // Zurücksetzen der Schriftgröße
                                        doc.setFontSize(currentFontSize);
                                    }
                                    else if(jQuery(alertContent[alertDivCons]).is("p")){
                                        var contentText = jQuery(alertContent[alertDivCons]).text();
                                        contentText = contentText.trim();
                                        contentText = gbuPDFReplaceSpecialCharacters(contentText);
                                        var contentTextArray = doc.splitTextToSize(contentText, maxContentWidth);
                                        for(var cText=0; cText < contentTextArray.length; cText++){
                                            // Zeile passt nicht mehr auf Seite
                                            if(currentHeightPosition + pdfMarginBottom > maxHeight){
                                                var docFontSize = doc.getFontSize();
                                                var docFontStyle = "normal";
                                                var result = gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, pdfCenter, pdfMarginTop, pdfMarginBottom, maxHeight);
                                                doc = result[0];
                                                currentHeightPosition = result[1];
                                            }
                                            var writeResult = gbuPDFWriteContent(doc, contentTextArray[cText], pdfMarginLeft, currentHeightPosition);
                                            doc = writeResult[0];
                                            currentHeightPosition = writeResult[1];
                                        }
                                    }
                                }
                                currentHeightPosition += 4;
                            }
                        }
                    }
                }
            }
        }

        var pdfTitle = "Auswertung";
        if(printBarChart && !printLineChart){
            pdfTitle += "_Mittelwerte";
        }
        else if(!printBarChart && printLineChart){
            pdfTitle += "_Haeufigkeiten";
        }
        else if(printBarChart && printLineChart){
            pdfTitle += "_gesamt";
        }
        doc.save(pdfTitle);
    }

    function gbuPDFWritePageNumber(doc, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginBottom, maxHeight){        
        doc.setFontSize(pageNumberFontSize);
        doc.setFont(pdfFont, pageNumberFontStyle);
        var currentTextColor = doc.getTextColor();
        doc.setTextColor(0,0,0);
        doc.text("-"+doc.page+"-", center, maxHeight-(marginBottom/2),{align:'center'});
        doc.setFontSize(docFontSize);
        doc.setFont(pdfFont, docFontStyle);
        doc.setTextColor(currentTextColor);
        return doc;
    }

    function gbuPDFAddNewPage(doc, pdfFormat, pdfOrientation, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginTop, marginBottom, maxHeight){
        doc.addPage(pdfFormat, pdfOrientation);
        var currentHeightPosition = marginTop;
        doc.page++;
        doc = gbuPDFWritePageNumber(doc, pdfFont, docFontSize, docFontStyle, pageNumberFontSize, pageNumberFontStyle, center, marginBottom, maxHeight);
        return [doc, currentHeightPosition];
    }

    function gbuPDFWriteContent(doc, content, marginLeft, currentHeightPosition){
        doc.text(content, marginLeft, currentHeightPosition);
        currentHeightPosition += doc.getFontSize()*0.352778+doc.getLineHeightFactor()*0.352778;
        return [doc, currentHeightPosition];
    }

    function gbuPDFReplaceSpecialCharacters(content){
        var changedContent = content.replace(/–/g,"-").replace(/…/g,"...").replace(/➔/g,"->").replace(/„/g, '"').replace(/“/g, '"').replace(/″/g, '"').replace(/’/g, "'");
        return changedContent; 
    }
</script>