开源软件名称(OpenSource Name):vsmoraes/pdf-laravel5开源软件地址(OpenSource Url):https://github.com/vsmoraes/pdf-laravel5开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):pdf-laravel5DOMPDF module for Laravel 5. Export your views as PDFs - with css support. InstalationAdd:
To your or Run:
Then add: Vsmoraes\Pdf\PdfServiceProvider::class To the And 'PDF' => 'Vsmoraes\Pdf\PdfFacade', To the UsageRoute::get('/pdf/view', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)->show();
}); Force downloadRoute::get('/pdf/download', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)->download();
}); Return PDF as stringRoute::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
return PDF::load($html)
->output();
}); Set paper size and orientation Route::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
return PDF::load($html, 'A4', 'landscape')
->output();
}); Output to a fileRoute::get('/pdf/output', function() {
$html = view('pdfs.example')->render();
PDF::load($html)
->filename('/tmp/example1.pdf')
->output();
return 'PDF saved';
}); Inject on your controller<?php namespace App\Http\Controllers;
use Vsmoraes\Pdf\Pdf;
class HomeController extends BaseControler
{
private $pdf;
public function __construct(Pdf $pdf)
{
$this->pdf = $pdf;
}
public function helloWorld()
{
$html = view('pdfs.example1')->render();
return $this->pdf
->load($html)
->show();
}
} ConfigurationDompdf allows you to configure a bunch of things on your PDF file. In previous versions we used to accomplish this through environment vars, now you can change this configuration keys on the fly: Route::get('/pdf/view', function() {
$html = view('pdfs.example')->render();
$defaultOptions = PDF::getOptions();
$defaultOptions->setDefaultFont('Courier');
return PDF::setOptions($defaultOptions)->load($html)->download();
}); For the complete configuration reference: Dompdf options |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论