I'm trying to create a PDF file via mPDF where the page continues. However, the second page write over the first
Code:
require_once ('../database/conection.php');
$db->query("SET NAMES 'utf8'");
$db->query("SET character_set_connection=utf8");
$db->query("SET character_set_client=utf8");
$db->query("SET character_set_results=utf8");
$sql = $db->query("SELECT * FROM movconsumo");
require_once __DIR__ . '/../vendor\autoload.php';
$mpdf = new \Mpdf\Mpdf();
$data = '';
while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
$data .= "<tr style='border: 1px solid black; border-collapse: collapse;'> <td style='border: 1px solid black; border-collapse: collapse;'>".$row['datamov']."</td>";
$data .= "<td style='border: 1px solid black; border-collapse: collapse;'>".$row['nomeitem']."</td>";
$data .= "<td style='border: 1px solid black; border-collapse: collapse;'><center>".$row['quantmov']."</center></td>";
$data .= "<td style='border: 1px solid black; border-collapse: collapse;'>".$row['destinomov']."</td>";
$data .= "<td style='border: 1px solid black; border-collapse: collapse;'>".$row['histmov'].'</td></tr>';
}
$mpdf->SetHTMLHeader('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 14pt; color: #000000; font-weight: bold; border-bottom:0.5mm solid #220044;">
<tr>
<td width="50%"><span style="font-weight: bold;">RELAT?�RIO ITENS MOVIMENTADOS</span></td>
<td width="45%" style="text-align: right;"><span style="font-size: 9pt;">teste<br /></span></td>
<td width="5%" style="text-align: right;"><img src="../images/teste.png" width="100" height="105" /></td>
</tr>
</table><br><center>
<table style="border: 1px solid black; border-collapse: collapse; ">
<tr style="border: 1px solid black; border-collapse: collapse; ">
<th>DATA</th>
<th>NOME</th>
<th>QUANTIDADE</th>
<th>DESTINO</th>
<th>HIST?�RICO</th>
</tr>
'.$data."</table></center>");
//#--> page
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->AddPage('L'); // Adds a new page in Landscape orientation L/P
//
$dia = date('d/m/y');
//#--> footer
$mpdf->SetHTMLFooter('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;">
<tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">'.$dia.'</span></td>
<td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
<td width="33%" style="text-align: right; ">Teste</td>
</tr>
</table>
');
$mpdf->Output();
I tried every way to keep the text going, however, it keeps writing on the first page. I am using mpdf 8.1 with yii2 and PHP version is 7.4 for PDF report download. It's works fine in local environment. But the text keeps writing on the first page.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Yii is a simple yet high performance generic component framework based framework. It is known for its high performance, but above all, it is famous for its simplicity. This framework appeared in December 2008. It allows you to use third-party code, and its Gii code generator allows you to quickly create basic structures from which you can build your own solutions.
https://www.yiiframework.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.