Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate multiple pdf files in a loop #493

frankguerra23 opened this issue Jul 19, 2019 · 1 comment


Copy link

commented Jul 19, 2019

Hi guys, i am facing this issue, want to generate a pdf file for every cicle of a loop i'm doing but it generates 1 pdf file for the first cicle and ignores the next n cicles, so i don't really know what could it be, i'll leave some of the code i'm using until now

in this first piece of code i create and loop arrays of ids which i query later in the print class to get the data that i am going to print

`foreach ($invoices as $inv) {

	$print_invoices =SetInvoicesId($inv);


So, once i get some ids i just send those to the code below, making some queries to get the data to print

`public function PrintInvoices(){
$this->pdf_string = '';
foreach ($this->invoicesId as $value) {

		$this->invoice= $this->GetInvoice($value);
		$this->products = $this->GetInvoiceProducts($value);


And here i just print the pdf
`public function PrintPdf(){

	   	$html2pdf = new HTML2PDF('L', array(215.9,140), 'Es', true, 'UTF-8', array(2, 0, 2, 0));
	   	$direc = 'File.pdf'; 
	   	$html2pdf->Output($direc, "D"); 
	}catch(HTML2PDF_exception $e) {
	    echo $e;

so guys this how i'm tryig to generate multiple files but isn't working at all, want you guys to help me out if you know what could be the problem


This comment has been minimized.

Copy link

commented Aug 1, 2019


You can't download multiple file, but you can save it on disk, and make a zip of it. It's the way i use it!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.