the table heads overlap I tried changing the margins on the pdfFromHTML5.js file, but still, it won't work, any ideas guys? these are the screenshot on the table and pdf file.
and I also tried using different codes already, like the jsPDF-Autotable, still no luck.
pdfFromHTML5.js
function HTMLtoPDF(){
var pdf = new jsPDF('p', 'pt', 'letter');
source = $('#HTMLtoPDF')[0];
specialElementHandlers = {
'#bypassme': function(element, renderer){
return true
}
}
margins = {
top: 50,
left: 60,
width: 545
};
pdf.fromHTML(
source // HTML string or DOM elem ref.
, margins.left // x coord
, margins.top // y coord
, {
'width': margins.width // max width of content on PDF
, 'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('html2pdf.pdf');
}
)
}
report-donators.php
<?php
include('includes/security.php');
include('includes/header.php');
include('includes/navbar.php');
?>
<div id="HTMLtoPDF">
<center><h1><span class="badge badge-primary">Current Donations</span></h1></center>
<hr>
<div class="table-responsive">
<?php
$query = "SELECT * FROM donators";
$query_run = mysqli_query($connection, $query);
?>
<table id="table" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%">
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Fullname</th>
<th>Date of donation (yyyy-mm-dd)</th>
<th>Email Address</th>
<th>Donated Via</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php
if(mysqli_num_rows($query_run) > 0)
{
while($row = mysqli_fetch_assoc($query_run))
{
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['fullname']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['donatedvia']; ?></td>
<td>Php. <?php echo $row['amount']; ?></td>
</tr>
<?php
}
}
else {
echo "No Records Found";
}
?>
</tbody>
</table>
</div>
</div>
<hr>
<center>
<a href="" class="btn btn-info" onclick="HTMLtoPDF()">Download PDF</a>
</center>
<!-- these js files are used for making PDF -->
<script src="js/jspdf.js"></script>
<script src="js/jquery-2.1.3.js"></script>
<script src="js/pdfFromHTML.js"></script>
<?php
include('includes/scripts.php');
include('includes/footer.php');
?>