1

Seguinte, estou tentando converter um arquivo HTML que tem uma tabela pra PDF usando a biblioteca HTML2PDF porém quando coloco uma tabela com o atributo border="1" o tabela fica assim:

Tabela

Meu código HTML:

<!doctype html>
<html lang="en-us">
<head>
    <title>Relatório de Tarefas</title>
    <style type="text/css">
        * {
            background: transparent !important;
            color: #000 !important;
            text-shadow: none !important;
            filter: none !important;
            -ms-filter: none !important;
        }

        body {
            margin: 0;
            padding: 0;
            line-height: 1.3em;
        }

        @page {
            margin: 0.5cm;
        }

        body {
            font: 10pt Arial, "Times New Roman", Times, serif;
            color: #000;
        }

        h1 {
            font-size: 24pt;
        }

        h2 {
            font-size: 18pt;
        }

        h3 {
            font-size: 14pt;
        }

        p {
            widows: 3;
            margin: 5px 0;
        }

        table {
            border-collapse: collapse;
            width: 100%;
        }

        table td, th {
            padding: 10px;
            text-align: left;
        }

        .to-center {
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>Relatório de Tarefas</h1>
    <p style="margin-top: -20px">Emitido em: {{ issueDate }}</p> <br/>
    <table border="1">
        <thead>
            <tr>
                <th class="to-center">#</th>
                <th>Assunto</th>
                <th>Descrição</th>
                <th class="to-center">Progresso</th>
                <th>Condomínio</th>
                <th class="to-center">Status</th>
                <th class="to-center">Criado em</th>
            </tr>
        </thead>
        <tbody>
            {% for task in tasks %}
                <tr>
                    <td class="to-center">{{ task.id }}</td>
                    <td>{{ task.subject }}</td>
                    <td>{{ task.description }}</td>
                    <td class="to-center">{{ task.percentage_progress }}%</td>
                    <td>{{ task.condominium_name }}</td>
                    <td class="to-center">{{ task.status_label }}</td>
                    <td class="to-center">{{ dateTimeConvert(task.created_at) }}</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
</body>

Alguém já teve esse problema ou sabe como resolver? Obrigado!

7
  • Tente colocando a borda pelo CSS tipo table { border: 1px solid black}
    – hugocsl
    17/12/2018 às 17:02
  • Deu no mesmo. O que não consigo ententer é que se eu tirar o atributo border funciona perfeitamente, porém a tabela fica sem a borda, e eu preciso dela :/ 17/12/2018 às 18:19
  • Tente colocar um <table style="box-shadow: 0 0 0 1px black"> as vezes funciona... faz um teste
    – hugocsl
    17/12/2018 às 18:23
  • 1
    Massa ;D posso postar como resposta?
    – hugocsl
    17/12/2018 às 18:32
  • 1
    Claro, pode sim! 17/12/2018 às 18:35

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .