繁体   English   中英

通过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存档中,并提供下载。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM