通过HTML2PDF循环下载我的pdf


Download my pdf in a loop through HTML2PDF

我想通过这个循环下载数据库中包含的所有pdf。当我点击按钮时,只下载第一个文件。

<?php
include_once('functions/functions.php');
require_once('../invoice/html2pdf.class.php');
if (isset($_GET['download'])) {
    if ($_GET['download'] == 'all') {
        $req = sql_query("SELECT * FROM invoice");
        $content = ''; 
        while ($res = mysqli_fetch_assoc($req)) {
            $html2pdf = new HTML2PDF('P', 'A4', 'fr');
            $html2pdf->setDefaultFont('Arial');
            $content = $res['content']; 
            $html2pdf->writeHTML($content);
            ob_end_clean();
            $html2pdf->Output('' . $res['date'] . '-' . $res['user'] . '.pdf', 'D');
        }
    }
}
?>
<panel class="panel panel-flat">
    <a href="invoice?download=all">Télécharger toutes les factures</a>
</panel>

每次下载只能提供1个文件。

当然,您可以将它们全部添加到zip档案中,并提供下载。