Author: Barry vd. Heuvel
Example #1
2
 public function generateTeamPDF(PDF $pdfCreator, Team $team)
 {
     $team = $team::find(Input::get('team'));
     $membersOfTeam = $team->users()->get();
     $pdf = $pdfCreator->loadView('pdf.teamHours', compact('membersOfTeam'));
     return $pdf->stream('Arbeitsstunden');
 }
 /**
  * Return a response with the PDF to show in the browser
  *
  * @param string $filename
  * @return \Illuminate\Http\Response 
  * @static 
  */
 public static function stream($filename = 'document.pdf')
 {
     return \Barryvdh\DomPDF\PDF::stream($filename);
 }
 public function generatePDF($id)
 {
     $input = array();
     $invoice = Bill::find($id);
     $input['invoice'] = $invoice;
     $input['id'] = $id;
     $company = Company::find($invoice->id);
     //$invoiceData = DB::table("invoice_detail")->where("invoice_id",$id);
     define('BUDGETS_DIR', './invoicexlxs/');
     // I define this in a constants.php file
     $pdfPath = "";
     if (!is_dir(BUDGETS_DIR)) {
         mkdir(BUDGETS_DIR, 0755, true);
     }
     $outputName = $fileurl = "RJLEX_" . strtoupper(substr($company->name, 0, 3)) . "_" . date("Y-M-d") . "_" . time() . ".pdf";
     // str_random is a [Laravel helper](http://laravel.com/docs/helpers#strings)
     $pdfPath = BUDGETS_DIR . '/' . $outputName;
     $invoice->pdf_url = $outputName;
     $invoice->update();
     // File::put($pdfPath, PDF::loadView($pdf, 'A4', 'portrait')->output());
     $pdf = PDF::loadView('invoicing.invoicepdf', $input)->setPaper('a4')->setOrientation('landscape')->save($pdfPath);
 }