1
Next, I’m trying to convert an HTML file that has a table to PDF using the library HTML2PDF
but when I put a table with the attribute border="1"
the table looks like this:
My HTML code:
<!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>
Has anyone ever had this problem or know how to solve it? Thank you!
Try placing the edge by the type CSS
table { border: 1px solid black}
– hugocsl
It was the same. What I can’t understand is that if I take the attribute
border
works perfectly, but the table is without the edge, and I need it :/– Gabriel Bitti
Try putting a
<table style="box-shadow: 0 0 0 1px black">
sometimes it works... takes a test– hugocsl
All right, I’ll see you test it here!
– Gabriel Bitti
It worked, brother! Thank you!
– Gabriel Bitti
Mass ;D I can post as response?
– hugocsl
Of course, you can!
– Gabriel Bitti