How to create two divs side by side using mPDF?

2

I've tried all kinds of style and I could not. I want to create two columns in the pdf.

   $html .= "<div class='row'>
                <span>INFORMAÇÕES DO COORDENADOR DO PROJETO</span>
                <hr></hr>
                <div>
                  <table>
                    <tbody>
                      <tr>
                        <td>Nome:</td>
                        <td>". $projeto->coordenador ."</td>
                      </tr>
                      <tr>
                        <td>CPF:</td>
                        <td>". $projeto->cpf ."</td>
                      </tr>
                      <tr>
                        <td>Sexo:</td>
                        <td>". $projeto->sexo ."</td>
                      </tr>
                      <tr>
                        <td>Telefone:</td>
                        <td>(00) 0000-0000,</td>
                        <td>(00) 0000-0000,</td>
                        <td>(00) 0000-0000</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
                <div>
                  <table style='padding-top: -80px; padding-left: 50%;'>
                    <tbody>
                      <tr>
                        <td>Titulação:</td>
                        <td>Mestre</td>
                      </tr>
                      <tr>
                        <td>E-mail:</td>
                        <td>". $projeto->email ."</td>
                      </tr>
                      <tr style='display:table;'>
                        <td>Link Curriculo Lattes:</td>
                        <td>". $projeto->link ."</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>";

In the first table I did not put style. Already on the second yes. I used Padding.

  

style = 'padding-top: -80px; padding-left: 50%; '

Here's how it goes:

Is there a way to do this?

    
asked by anonymous 02.02.2016 / 17:49

1 answer

6

Come on,

You do not need to write inline css in mpdf, at the end just add:

$mpdf->WriteHTML($stylesheet, 1); // seu css
$mpdf->WriteHTML($html, 2); // seu html

I recommend testing first in html and then convert to pdf, if something comes out different in pdf check the list of css supported items in mpdf: Supported CSS attributes

I added two classes, LEFT / RIGHT to accomplish this separation.

Example:

<?php

$stylesheet = ".right {
  float: right;
  width: 50%;
}

.left {
  float: left;
  width: 50%;
}
body{
   font-size:12px;
}
";


$html = "<div class='row'>
  <span>INFORMAÇÕES DO COORDENADOR DO PROJETO</span>
  <hr>
  <div class='left'>
    <table>
      <tbody>
        <tr>
          <td>Nome:</td>
          <td> PROJETO->COORDENADOR </td>
        </tr>
        <tr>
          <td>CPF:</td>
          <td> PROJETO->CPF</td>
        </tr>
        <tr>
          <td>Sexo:</td>
          <td>PROJETO->SEXO</td>
        </tr>
        <tr>
          <td>Telefone:</td>
          <td>(00) 0000-0000,(00) 0000-0000,(00) 0000-0000</td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class='right'>
    <table>
      <tbody>
        <tr>
          <td>Titulação:</td>
          <td>Mestre</td>
        </tr>
        <tr>
          <td>E-mail:</td>
          <td>PROJETO->EMAIL</td>
        </tr>
        <tr>
          <td>Link Curriculo Lattes:</td>
          <td>PROJETO->LINK</td>
        </tr>
      </tbody>
    </table>
  </div>
";

include 'lib/mpdf/mpdf.php';
$mpdf = new mPDF();
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html, 2);
$mpdf->Output('exemplo.pdf', 'I');

How was it:

    
02.02.2016 / 18:47