contact_sheet_add_fields($result[$n]); #Add image contact_sheet_add_image(); } else { if ($sheetstyle == "single") { #Add image contact_sheet_add_image(); #render fields contact_sheet_add_fields($result[$n]); } } } } $n = $n++; if ($i == $columns) { $pdf->ln(); $i = 0; $j++; if ($j > $rowsperpage || $sheetstyle == "single") { $j = 0; if ($n < count($result) - 1) { //avoid making an additional page if it will be empty $pdf->AddPage(); $pdf->SetX(1); $pdf->SetY(1.2 + $logospace); } } } } } }