Parakh Chauhan
Parakh Chauhan

Reputation: 15

Is there any way to dynamically create new page in php TCPDF library with respect to an array with values

I'm just stuck in this new problem in which I have to create a recommendation for a user's pet with a help of the PHP TCPDF library, In this situation, I have a form in which a user enters numbers of pets and their details.

The problem is I don't know how many numbers of pets a user have and I can't use a loop inside a TCPDF library. As I want to create a new page or new PDF for every single pet details user has.

Basically, i want to replace a variable inside $html = <<<EOD EOD;

Upvotes: 0

Views: 392

Answers (1)

Simone Rossaini
Simone Rossaini

Reputation: 8162

You can use your loop with AddPage(); method like:

foreach($array as $data){
  $pdf->writeHTML($data);
  $pdf->AddPage();
}

Upvotes: 1

Related Questions