update v1.0.3.3

This commit is contained in:
sujitprasad
2015-12-22 14:09:23 +05:30
parent 2bc3db252e
commit 696e0390fe
8590 changed files with 3456 additions and 818 deletions

View 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
View 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]);
}

View 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';
}
}

View 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'];
}
}