Problemas com Header e footer em relatorio com mPHP

1 resposta
php
A

Boa noite galera,

Estou dando uma olhada no mphp pra aprender a fazer relatorios com php, devido a um caso q ocorreu no meu trabalho, agora quero me precaver e aprender a usar tal ferramenta, mas estou com problemas(tentei fazer semelhante ao do trabalho).

não consigo colocar header e footer no formulário, j´q tentei de varias formas que vi na internet, mas nada funcionou.

será q alguem pode me ajudar?

cada variavel que eu colocar aqui está no msm arquivo, só vou separar pra facilitar a visualização
segue o codigo:

CSS:

$css="

@page {
                margin-left: 20px;
                margin-right: 20px;
                margin-top: 15px;
                margin-bottom: 15px;
            }
#cabecInicial{
                font-family: 'Century Gothic';
                color: #3864B2;
                background-image: url('imgs/cabecalho_relatorios_1_grande.png');
                background-position: right top;
                background-repeat: no-repeat;
                background-size: 70% 120%;
                background-color: #efefef;
                height: 160px;
                width: 100%;
            }
#corpoCabecInicial{
                height: 115px;
                width: 100%;
                float: left;
                margin-top: 15px;
            }
#dadosCabec {
                float: left;
                margin-left: 15px;
                width: 430px;
            }
#corpoRelatCompleto{
                height: auto;//100%;//200px
                width: 100%;//1035    
                margin:0 auto;
            }
.esquerdaEspaco10 {
                padding-left: 5px;
            }
.subtitulo{
                font-weight: bolder;
                vertical-align: top;
            }
.apertoDeMao{
                width: 154px;
            }
.apertoDeMaoMini{
                float: left;
                width: 78px;
                margin: 8px;
            }
#infoCabecInicial {
                vertical-align: bottom;
                font-size: 12px;
                
            }
#obsCabec{
                opacity: 0.7;
                background: #144385;
                padding-left: 10px;
                padding-right: 5px;
                padding-top: 20px;
                padding-bottom: 20px;
                margin-left: 20px;
                margin-top: 5px;
                margin-right: 20px;
                width: 230px;
                height: auto;
                color: #fff;
                float: right;
                border-radius: 15px 15px 15px 15px;
                box-shadow: 3px -4px 3px 0px #336abd;
            }
.textoFooter {
                margin-top: 20px;
                padding-right: 15px;
                float: right;
                color: #ffffff;
            }
.footer {
                background: url('imgs/footerGambi.png');
                background-repeat: no-repeat;
                background-size: 100%;
                width: 100%;
                height: 50px;
                text-align: right;
                clear: both;
                //page-break-after:always;
                //position: fixed;
            }
.basicHeader {
                background-image: url('imgs/cabecalho_relatorios_1.png');
                background-position: right top;
                background-repeat: no-repeat;
                background-size: 70% 180%;
                background-color: #efefef;
                width: 100%;
                height: 70px;
                clear: both
                font-size: 12px;
                float: left;
                position: fixed; top: 0px;//page-break-after:always;
            }
.textoCabecGeral {
                float: left;
                font-size: 26px;
                color: #3864B2;
                width: 500px;
            }
#corpoRelat {
                margin-top:65px;
                font-family: 'Tw Cen MT';
                font-size: 12.0pt;
            }
.indice {    
                font-size: 22pt;
                border-bottom: 1px double;
                padding-bottom: 5px;
            }
.numeroIndice {
                padding-right: 15px;
            }
.subIndice {
                font-weight: bolder;
            }
.tabelaSistema {
                width: 100%;
                border-collapse: collapse;
                margin-bottom: 35px;
            }
.tabelaSistema td{
                border: 1px solid #000000;    
            }
.tabelaSistema th{
                border: 1px solid #000000;    
            }
.tabelaSistema .tdLess {
                width: 15%;
                text-align: center;
            }
.tabelaSistema .first {
                text-align: left;
                padding-left: 15px;
            }
#cabecTable {
                width: 100%;
            }
            
        </style>"    
;

header da 1ª pagina:

$firstCabec = '
    
                                    <div id="cabecInicial">

                                        <div id="corpoCabecInicial">
                                            
                                                    <div style="height: 23px;"></div>
                                                    
                                                        <div id="dadosCabec">
                                                            <table>
                                                                <tbody><tr>
                                                                    <td rowspan="2">
                                                                        <img src="./2016.07.12 relato_de_----.pdf_files/maoGambi.png" class="apertoDeMao">
                                                                    </td>
                                                                    <td class="subtitulo esquerdaEspaco10">
                                                                        RELATO DIÁRIO
                                                                        <br>Gerenciamento do ------------
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td id="infoCabecInicial" class="esquerdaEspaco10">
                                                                        #-------
                                                                        <br>08/08/2016
                                                                        <br>-------
                                                                    </td>
                                                                </tr>
                                                            </tbody></table>
                                                        </div>
                                                    
                                                    
                                                        <div id="obsCabec">
                                                            Principais ........ ++++++++ -----------.
                                                        </div>
                                                    
                                            
                                            
                                            
                                            
                                            
                                        </div>

                                    </div>
    
    
    ';

corpo:

$corpo = '
    
                <div id="corpoRelatCompleto">
                
                    
                    texto totalmente aleatório gerado pelo Lorem Ipsum
                
                </div>
                    
                

    
    ';

Juntando o html:

$pdfCompleto = $css.$inicioCorpo.$firstCabec.$corpo.$fimCorpo;

MPDF:

require_once ('mpdf60/mpdf.php'); 

$mpdf = new mPDF(); 
$mpdf->SetHTMLHeader($header, "E");
$mpdf->SetHTMLFooter($footer,"O");

$mpdf->charset_in='windows-1252'; 

$mpdf->WriteHTML($pdfCompleto);
$mpdf->Output();

1 Resposta

A

up

Criado 8 de agosto de 2016
Ultima resposta 11 de ago. de 2016
Respostas 1
Participantes 1