update v1.0.3.3
This commit is contained in:
3
vendor/vsmoraes/laravel-pdf/.gitignore
vendored
Normal file
3
vendor/vsmoraes/laravel-pdf/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
composer.lock
|
||||
/vendor
|
||||
.idea
|
9
vendor/vsmoraes/laravel-pdf/.travis.yml
vendored
Normal file
9
vendor/vsmoraes/laravel-pdf/.travis.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
before_script:
|
||||
- composer install --prefer-source
|
0
vendor/vsmoraes/laravel-pdf/LICENSE
vendored
Normal file
0
vendor/vsmoraes/laravel-pdf/LICENSE
vendored
Normal file
89
vendor/vsmoraes/laravel-pdf/README.md
vendored
Normal file
89
vendor/vsmoraes/laravel-pdf/README.md
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# pdf-laravel5
|
||||
|
||||
DOMPDF module for Laravel 5
|
||||
|
||||
[](https://travis-ci.org/vsmoraes/pdf-laravel5)
|
||||
[](https://packagist.org/packages/vsmoraes/laravel-pdf)
|
||||
|
||||
## Instalation
|
||||
Add:
|
||||
```
|
||||
"vsmoraes/laravel-pdf": "dev-master"
|
||||
```
|
||||
To your `composer.json`
|
||||
|
||||
or Run:
|
||||
```
|
||||
composer require vsmoraes/laravel-pdf
|
||||
```
|
||||
|
||||
Then add:
|
||||
```php
|
||||
'Vsmoraes\Pdf\PdfServiceProvider'
|
||||
```
|
||||
To the `providers` array on your `config/app.php`
|
||||
|
||||
And
|
||||
|
||||
```php
|
||||
'PDF' => 'Vsmoraes\Pdf\PdfFacade',
|
||||
```
|
||||
To the `aliases` array on yout `config/app.php` in order to enable the PDF facade
|
||||
|
||||
## Usage
|
||||
|
||||
```php
|
||||
$router->get('/pdf/view', function() {
|
||||
$html = view('pdfs.example')->render();
|
||||
|
||||
return PDF::load($html)->show();
|
||||
});
|
||||
```
|
||||
|
||||
### Force download
|
||||
```php
|
||||
$router->get('/pdf/download', function() {
|
||||
$html = view('pdfs.example')->render();
|
||||
|
||||
return PDF::load($html)->download();
|
||||
});
|
||||
```
|
||||
|
||||
### Output to a file
|
||||
```php
|
||||
$router->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
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
```
|
21
vendor/vsmoraes/laravel-pdf/composer.json
vendored
Normal file
21
vendor/vsmoraes/laravel-pdf/composer.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "vsmoraes/laravel-pdf",
|
||||
"description": "DOMPDF module for Laravel 5",
|
||||
"keywords": ["laravel", "dompdf", "pdf"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{ "name": "Vinicius Moraes", "email": "vinicius@archlinux.com.br" }
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"dompdf/dompdf": "0.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.4.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Vsmoraes\\Pdf\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
8
vendor/vsmoraes/laravel-pdf/phpunit.xml
vendored
Normal file
8
vendor/vsmoraes/laravel-pdf/phpunit.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit colors="true" bootstrap="tests/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite name="DomPdf tests">
|
||||
<directory suffix=".php">tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
116
vendor/vsmoraes/laravel-pdf/src/Dompdf.php
vendored
Normal file
116
vendor/vsmoraes/laravel-pdf/src/Dompdf.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace Vsmoraes\Pdf;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class Dompdf implements Pdf
|
||||
{
|
||||
/**
|
||||
* DOMPDF instance
|
||||
*
|
||||
* @var \DOMPDF
|
||||
*/
|
||||
protected $dompdfInstance;
|
||||
|
||||
/**
|
||||
* Path to the PDF
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filename = 'dompdf_out.pdf';
|
||||
|
||||
|
||||
/**
|
||||
* Inject the DOMPDF object
|
||||
*
|
||||
* @param \DOMPDF $dompdf
|
||||
*/
|
||||
public function __construct(\DOMPDF $dompdf)
|
||||
{
|
||||
$this->dompdfInstance = $dompdf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($html, $size = 'A4', $orientation = 'portrait')
|
||||
{
|
||||
$this->dompdfInstance->load_html($html);
|
||||
$this->setPaper($size, $orientation);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function filename($filename = null)
|
||||
{
|
||||
if ($filename) {
|
||||
$this->filename = $filename;
|
||||
|
||||
// chain when the filename is set
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPaper($size, $orientation)
|
||||
{
|
||||
return $this->dompdfInstance->set_paper($size, $orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->dompdfInstance->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
\Image_Cache::clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function show($options = ['compress' => 1, 'Attachment' => 0])
|
||||
{
|
||||
$this->render();
|
||||
$this->clear();
|
||||
|
||||
return $this->dompdfInstance->stream($this->filename(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function download($options = ['compress' => 1, 'Attachment' => 1])
|
||||
{
|
||||
return new Response($this->show($options), 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function output($options = ['compress' => 1])
|
||||
{
|
||||
$this->render();
|
||||
|
||||
return $this->dompdfInstance->output($options);
|
||||
}
|
||||
}
|
71
vendor/vsmoraes/laravel-pdf/src/Pdf.php
vendored
Normal file
71
vendor/vsmoraes/laravel-pdf/src/Pdf.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace Vsmoraes\Pdf;
|
||||
|
||||
interface Pdf
|
||||
{
|
||||
/**
|
||||
* Loads the HTML to the DOMPDF class
|
||||
*
|
||||
* @param $html
|
||||
* @param string $size
|
||||
* @param string $orientation
|
||||
* @return mixed
|
||||
*/
|
||||
public function load($html, $size = 'A4', $orientation = 'portrait');
|
||||
|
||||
/**
|
||||
* Set the filename (full path) to where the file should be saved
|
||||
*
|
||||
* @param null $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public function filename($filename = null);
|
||||
|
||||
/**
|
||||
* Set paper size
|
||||
*
|
||||
* @param $size
|
||||
* @param $orientation
|
||||
* @return mixed
|
||||
*/
|
||||
public function setPaper($size, $orientation);
|
||||
|
||||
/**
|
||||
* Render the pdf
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function render();
|
||||
|
||||
/**
|
||||
* Clear the pdf
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function clear();
|
||||
|
||||
/**
|
||||
* Render the pdf on the browser
|
||||
*
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($options = ['compress' => 1, 'Attachment' => 0]);
|
||||
|
||||
/**
|
||||
* Forces the pdf to download
|
||||
*
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
*/
|
||||
public function download($options = ['compress' => 1, 'Attachment' => 0]);
|
||||
|
||||
/**
|
||||
* Output the pdf the to file speficied on $this->filename()
|
||||
*
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
*/
|
||||
public function output($options = ['compress' => 1]);
|
||||
|
||||
}
|
17
vendor/vsmoraes/laravel-pdf/src/PdfFacade.php
vendored
Normal file
17
vendor/vsmoraes/laravel-pdf/src/PdfFacade.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Vsmoraes\Pdf;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class PdfFacade extends Facade
|
||||
{
|
||||
/**
|
||||
* Return the facade name accessor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'Vsmoraes\Pdf\Pdf';
|
||||
}
|
||||
}
|
44
vendor/vsmoraes/laravel-pdf/src/PdfServiceProvider.php
vendored
Normal file
44
vendor/vsmoraes/laravel-pdf/src/PdfServiceProvider.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace Vsmoraes\Pdf;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Vsmoraes\Pdf\Dompdf as MyDompdf;
|
||||
|
||||
class PdfServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register the classes on the IoC container
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind('DOMPDF', function() {
|
||||
return new \DOMPDF();
|
||||
});
|
||||
|
||||
$this->app->bind('Vsmoraes\Pdf\Pdf', function() {
|
||||
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
||||
|
||||
require_once base_path() . '/vendor/dompdf/dompdf/dompdf_config.inc.php';
|
||||
|
||||
return new Dompdf(new \DOMPDF());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return ['Vsmoraes\Pdf\Pdf'];
|
||||
}
|
||||
}
|
6
vendor/vsmoraes/laravel-pdf/tests/bootstrap.php
vendored
Normal file
6
vendor/vsmoraes/laravel-pdf/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
define('DOMPDF_ENABLE_AUTOLOAD', false);
|
||||
require_once __DIR__ . '/../vendor/dompdf/dompdf/dompdf_config.inc.php';
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
34
vendor/vsmoraes/laravel-pdf/tests/src/DompdfTest.php
vendored
Normal file
34
vendor/vsmoraes/laravel-pdf/tests/src/DompdfTest.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class DompdfTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testLoadHtml()
|
||||
{
|
||||
$stub = $this->getMockBuilder('\DOMPDF')
|
||||
->setMethods(['load_html'])
|
||||
->getMock();
|
||||
|
||||
$pdf = new \Vsmoraes\Pdf\Dompdf($stub);
|
||||
|
||||
$stub->expects($this->once())
|
||||
->method('load_html');
|
||||
|
||||
$pdf->load('<html><head></head><body></body></html>');
|
||||
}
|
||||
|
||||
public function testShowHtml()
|
||||
{
|
||||
$stub = $this->getMockBuilder('\DOMPDF')
|
||||
->getMock();
|
||||
|
||||
$pdf = new \Vsmoraes\Pdf\Dompdf($stub);
|
||||
|
||||
$stub->expects($this->once())
|
||||
->method('stream');
|
||||
|
||||
$pdf->load('<html><head></head><body></body></html>');
|
||||
$pdf->show();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user