J'utilise CodeIgniter avec la bibliothèque mpdf pour créer des fichiers pdf.Erreur liée à l'utilisation du pied de page de la bibliothèque mpdf
Cela fonctionne très bien jusqu'à ce que j'essaie d'ajouter un pied de page. Chaque fois que j'ajouter le pied de page, chaque fois que je tente d'ouvrir le fichier généré je reçois cette erreur:
File Does Not Begin With '%PDF-' Local\EWH-6160-0
Si je saute le pied de page, il fonctionne très bien, je ne comprends pas comment l'erreur est liée à la bas de page.
C'est le contrôleur qui crée le pdf:
public function print_beneficiaries($cod){
$mpdf = new mPDF('utf-8', 'A3');
$name = $this->natural_md->client_name($cod);
$account = $this->formats->retrieve_account($cod);
$data = $this->formats->beneficiaries($cod);
$date = $this->formats->mult_contract($cod);
$list = array();
if($data > 0){
$i = 1;
foreach ($data as $benef){
array_push($list, array(
'cod' => $cod,
'id_beneficiary' => $benef['id_beneficiary'],
'name' => $benef['beneficiary_name'],
'relationship' => $benef['relationship'],
'benef_percentage' => $benef['benef_percentage'],
'identification' => $benef['identification'],
'identification_type' => $benef['identification_type'],
'address' => $benef['address'],
'email' => $benef['email'],
'telephone' => $benef['telephone'],
'celphone' => $benef['celphone'],
'letter' => $this->utilities->get_letter($i)
));
$i = $i + 1;
}
}
else
$list = array();
$mpdf->SetFooter("{PAGENO}/{nb}");
$mpdf->WriteHTML($this->load->view('pdf/pn_beneficiaries', array(
'list' => $list,
'account_name' => ucwords($name[0]['names']),
'account_id' => $account == null ? 0 : $account->id,
'account' => $account == '' ? 0 :$cuenta->account_name,
'day' => sprintf('%02d', $date[0]['day']),
'month' => sprintf('%02d', $date[0]['month']),
'year' => $date[0]['year'],
), true));
$mpdf->Output("Beneficiaries - ".$cod.".pdf", "I");
}
La vue à partir de laquelle le contrôleur récupère les données est la suivante:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Beneficiaries</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<?php echo base_url();?
>/assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo base_url();?
>/assets/css/font.css" />
<style>
body{
color: #0a0a0a;
font-size: 12px;
font-family: Calibri, sans-serif;
}
.foot{
position: absolute;
bottom: 0;
left: 900px;
width: 100%;
float: right;
}
.espacio{
margin-top: 4px;
width: 900px;
}
.espacio h3{
text-align: center;
font-weight: 700;
}
.per{
font-size: 14px;
text-align: justify;
}
table{
font-size: 16px;
}
th{
padding:4px;
text-align: center;
}
table.border td{
border: solid 2px #B1B1B1;
}
td{
padding:4px;
}
u{
height: 2px;
}
.logo{
text-align: center;
}
@media print {
#with_print {
display: none;
}
}
</style>
</head>
<body>
<header>
<div class="row">
<div class="container logo">
<img src="<?php echo base_url();?>/assets/img/logo-inver-
new.jpg" width="180px">
</div>
</div>
</header>
<div class="container espacio" >
<h3>
Beneficiary designation
</h3>
<div class="espacio per">
<p>
some text
</p>
</div>
<div class="row">
<div class="container">
<table border="1" class="border">
<tr>
<td colspan="3" style=" background-color: #30859B; color: #fff;
font-size: 16px; margin: 5px;">Fecha</td>
</tr>
<tr>
<td style=" font-size: 16px;"><?php echo $day; ?></td>
<td style=" font-size: 16px;"><?php echo $month; ?></td>
<td style=" font-size: 16px;"><?php echo $year; ?></td>
</tr>
</table>
</div>
</div>
<br>
<div class="row">
<?php $cont = 0; $filas=count($list);?>
<?php foreach ($list as $row):?>
<div class="container">
<table border="1" align="center" class="border">
<tr>
<td colspan="2" style=" background-color: #30859B; color:
#fff;">Beneficiario <?php echo $row['letter']; ?></td>
</tr>
<tr>
<td colspan="2">Nombre del Beneficiario: <span style="font-
size: 18px; font-style: italic; color:
#2b2b2b;">  <?php echo $row['name']; ?> </span>
</td>
</tr>
<tr>
<td style="width: 500px;">Parentesco: <span style="font-
size: 18px; font-style: italic; color:
#2b2b2b;">  <?php echo $row['relationship']; ?>
</span> </td>
<td style="width: 500px;">% del Beneficiario: <span
style="font-size: 18px; font-style: italic; color:
#2b2b2b;">  
<?php
if(!empty($row['benef_percentage']))
{echo $row['benef_percentage'].' %';}
?></span> </td>
</tr>
<tr>
<td>No. Identificación: <span style="font-size: 18px; font-
style: italic; color: #2b2b2b;">  <?php echo
$row['identification']; ?></span> </td>
<td>Tipo de Identificación: <span style="font-size: 18px;
font-style: italic; color: #2b2b2b;">  <?php echo
$row['identification_type']; ?> </span> </td>
</tr>
<tr>
<td colspan="2">Dirección del Beneficiario: <span
style="font-size: 18px; font-style: italic; color:
#2b2b2b;">   <?php echo $row['address']; ?>
</span> </td>
</tr>
<tr>
<td colspan="2">Correo Electrónico: <span style="font-size:
18px; font-style: italic; color: #2b2b2b;">   <?
php echo $row['email']; ?></span> </td>
</tr>
<tr>
<td>Teléfono Domicilio: <span style="font-size: 18px; font-
style: italic; color: #2b2b2b;">  <?php echo
$row['telephone']; ?></span> </td>
<td>Teléfono Celular: <span style="font-size: 18px; font-
style: italic; color: #2b2b2b;">  <?php echo
$row['celphone']; ?> </span> </td>
</tr>
</table>
</div>
<?php $cont++;
if ($cont%5==0 && $filas>5) {
echo '
<pagebreak>
';
}
?>
<?php endforeach; ?>
</div>
<br>
<div class="col-xs-12">
<table style="margin-top: 10px;">
<tr>
<td>Nombre de la cuenta: <?php echo $filas ?></td>
<td style="border-bottom: solid 1px #000; width: 100%"><?php
if (isset($account) && ($account!='')) {
echo $account;
}else{
echo $account_name;
}
?></td>
</tr>
</table>
</div>
<div class="col-xs-12 espacio">
<p style="text-align: justify;"><span style=" font-weight:
bold;">Nota:</span>Other text</p>
</div>
<div class="col-xs-12">
<table style="margin-top: 10px;">
<tr >
<td style="width: 100px;"></td>
<td style="border-top: solid 1px #000; width: 250px; text-
align: center; font-size: 16px;" >Firma del Cliente</td>
<td style="width: 100px;"></td>
<td style="border-top: solid 1px #000; ; width: 350px; text-
align: center; font-size: 16px;" >Firma del
Cliente<br>Cuenta Mancomunada</td>
<td style="width: 100px;"></td>
<td style="border-top: solid 1px #000;width: 290px; text-
align: center; font-size: 16px;">
Firma del Funcionario IPB
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
il vous manque '' 'dans' 'address => $ benef [' address '], '. le remplacer par ''adresse '=> $ benef [' adresse '],'. – Regolith
Si le message vous indique que le fichier ne commence pas par [...], la première chose à faire est d'aller ouvrir ce fichier dans un éditeur de texte, pour voir ce qu'il contient _actually_. Assez sûr que ce serait dans ce cas un message d'erreur PHP. – CBroe
Pour une raison quelconque, lorsque j'ai copié mon code pour le post j'ai raté le '. Dans mon code actuel, je l'ai bien, donc j'ai toujours l'erreur et ça me conduit maaaaad haha. – nova