title: Multi-page pdf using barryvdh dompdf Laravel-4 and loadView rather than loadHtml
body: <p>I'm trying to create batched pdf invoices (using: <a href="https://github.com/barryvdh/laravel-dompdf" rel="nofollow">barryvdh/laravel-dompdf</a>) that can be downloaded and printed. Sending the invoices via email is easy because the 'send' command works perfectly inside a loop and will attach the currently created pdf, but $pdf->download() requires a return response -- my attempts to download without "return" get an error message, and "return" of course breaks the loop. Since my invoices are complicated, I'm using </p>
  
  <pre><code>    $pdf-&gt;loadView('invoices.show',$data);
  </code></pre>
  
  <p>to create the invoice using a view, rather than trying to write all of the html in the controller. I'm fine with combining all of the invoices into a single, multi-page pdf. I understand the trick of using css style="page-break-after" to create different pages, but I can't figure out how to do that when I'm using loadView in order to send page-specific $data, rather than loadHtml -- loadView always results in only the last invoice being included.</p>
  
  <p>For example, controller:</p>
  
  <pre><code>public function invoices()
  {
      $pdf = App:make('dompdf');
      for($i=0; $i&lt;4; $i++) {
      $data = array('i'=&gt;$i);
      }
  $pdf-&gt;loadView('invoices.show',$data);
  return $pdf-&gt;download("Invoice");
  }
  </code></pre>
  
  <p>(I'm only including a single variable in the example $data array here; the real invoices obviously have a lot of $data variables.)</p>
  
  <p>View, wrapped in:</p>
  
  <pre><code>&lt;div style="page-break-after:always;"&gt;
  </code></pre>
  
  <p>Only returns, where the Invoice # = $i</p>
  
  <pre><code>Invoice #3
  </code></pre>
  
  <p>Of course, putting $pdf->loadView inside of the loop does exactly the same thing. And since $pdf is not a string, trying something like $pdf .= ... within the loop doesn't work.</p>
  
  <p>Thanks for any suggestions.</p>