Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
15
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/Facades/Pdf.php
vendored
Normal file
15
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/Facades/Pdf.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace niklasravnsborg\LaravelPdf\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade as BaseFacade;
|
||||
|
||||
class Pdf extends BaseFacade {
|
||||
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor() { return 'mpdf.wrapper'; }
|
||||
}
|
||||
154
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/Pdf.php
vendored
Normal file
154
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/Pdf.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace niklasravnsborg\LaravelPdf;
|
||||
|
||||
use Config;
|
||||
use Mpdf;
|
||||
|
||||
/**
|
||||
* Laravel PDF: mPDF wrapper for Laravel 5
|
||||
*
|
||||
* @package laravel-pdf
|
||||
* @author Niklas Ravnsborg-Gjertsen
|
||||
*/
|
||||
class Pdf {
|
||||
|
||||
protected $config = [];
|
||||
|
||||
public function __construct($html = '', $config = [])
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
// @see https://mpdf.github.io/reference/mpdf-functions/construct.html
|
||||
$mpdf_config = [
|
||||
'mode' => $this->getConfig('mode'), // Mode of the document.
|
||||
'format' => $this->getConfig('format'), // Can be specified either as a pre-defined page size, or as an array of width and height in millimetres
|
||||
'default_font_size' => $this->getConfig('default_font_size'), // Sets the default document font size in points (pt).
|
||||
'default_font' => $this->getConfig('default_font'), // Sets the default font-family for the new document.
|
||||
'margin_left' => $this->getConfig('margin_left'), // Set the page margins for the new document.
|
||||
'margin_right' => $this->getConfig('margin_right'), // Set the page margins for the new document.
|
||||
'margin_top' => $this->getConfig('margin_top'), // Set the page margins for the new document.
|
||||
'margin_bottom' => $this->getConfig('margin_bottom'), // Set the page margins for the new document.
|
||||
'margin_header' => $this->getConfig('margin_header'), // Set the page margins for the new document.
|
||||
'margin_footer' => $this->getConfig('margin_footer'), // Set the page margins for the new document.
|
||||
'orientation' => $this->getConfig('orientation'), // This attribute specifies the default page orientation of the new document if format is defined as an array. This value will be ignored if format is a string value.
|
||||
'tempDir' => $this->getConfig('tempDir') // temporary directory
|
||||
];
|
||||
|
||||
// Handle custom fonts
|
||||
$mpdf_config = $this->addCustomFontsConfig($mpdf_config);
|
||||
|
||||
$this->mpdf = new Mpdf\Mpdf($mpdf_config);
|
||||
|
||||
// If you want to change your document title,
|
||||
// please use the <title> tag.
|
||||
$this->mpdf->SetTitle('Document');
|
||||
|
||||
$this->mpdf->SetAuthor ( $this->getConfig('author') );
|
||||
$this->mpdf->SetCreator ( $this->getConfig('creator') );
|
||||
$this->mpdf->SetSubject ( $this->getConfig('subject') );
|
||||
$this->mpdf->SetKeywords ( $this->getConfig('keywords') );
|
||||
$this->mpdf->SetDisplayMode ( $this->getConfig('display_mode') );
|
||||
|
||||
if (!empty($this->getConfig('pdf_a'))) {
|
||||
$this->mpdf->PDFA = $this->getConfig('pdf_a'); // Set the flag whether you want to use the pdfA-1b format
|
||||
$this->mpdf->PDFAauto = $this->getConfig('pdf_a_auto'); // Overrides warnings making changes when possible to force PDFA1-b compliance;
|
||||
}
|
||||
|
||||
if (!empty($this->getConfig('icc_profile_path'))) {
|
||||
$this->mpdf->ICCProfile = $this->getConfig('icc_profile_path'); // Specify ICC colour profile
|
||||
}
|
||||
|
||||
if (isset($this->config['instanceConfigurator']) && is_callable(($this->config['instanceConfigurator']))) {
|
||||
$this->config['instanceConfigurator']($this->mpdf);
|
||||
}
|
||||
|
||||
$this->mpdf->WriteHTML($html);
|
||||
}
|
||||
|
||||
protected function getConfig($key)
|
||||
{
|
||||
if (isset($this->config[$key])) {
|
||||
return $this->config[$key];
|
||||
} else {
|
||||
return Config::get('pdf.' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
protected function addCustomFontsConfig($mpdf_config)
|
||||
{
|
||||
if (!Config::has('pdf.font_path') || !Config::has('pdf.font_data')) {
|
||||
return $mpdf_config;
|
||||
}
|
||||
|
||||
// Get default font configuration
|
||||
$fontDirs = (new Mpdf\Config\ConfigVariables())->getDefaults()['fontDir'];
|
||||
$fontData = (new Mpdf\Config\FontVariables())->getDefaults()['fontdata'];
|
||||
|
||||
// Merge default with custom configuration
|
||||
$mpdf_config['fontDir'] = array_merge($fontDirs, [Config::get('pdf.font_path')]);
|
||||
$mpdf_config['fontdata'] = array_merge($fontData, Config::get('pdf.font_data'));
|
||||
|
||||
return $mpdf_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts and sets the PDF document permissions
|
||||
*
|
||||
* @param array $permisson Permissons e.g.: ['copy', 'print']
|
||||
* @param string $userPassword User password
|
||||
* @param string $ownerPassword Owner password
|
||||
* @return static
|
||||
*
|
||||
*/
|
||||
public function setProtection($permisson, $userPassword = '', $ownerPassword = '')
|
||||
{
|
||||
if (func_get_args()[2] === NULL) {
|
||||
$ownerPassword = bin2hex(openssl_random_pseudo_bytes(8));
|
||||
};
|
||||
return $this->mpdf->SetProtection($permisson, $userPassword, $ownerPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the PDF as a string.
|
||||
*
|
||||
* @return string The rendered PDF as string
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
return $this->mpdf->Output('', 'S');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the PDF to a file
|
||||
*
|
||||
* @param $filename
|
||||
* @return static
|
||||
*/
|
||||
public function save($filename)
|
||||
{
|
||||
return $this->mpdf->Output($filename, 'F');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the PDF downloadable by the user
|
||||
*
|
||||
* @param string $filename
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function download($filename = 'document.pdf')
|
||||
{
|
||||
return $this->mpdf->Output($filename, 'D');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a response with the PDF to show in the browser
|
||||
*
|
||||
* @param string $filename
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function stream($filename = 'document.pdf')
|
||||
{
|
||||
return $this->mpdf->Output($filename, 'I');
|
||||
}
|
||||
}
|
||||
56
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/PdfServiceProvider.php
vendored
Normal file
56
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/PdfServiceProvider.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace niklasravnsborg\LaravelPdf;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
||||
|
||||
class PdfServiceProvider extends BaseServiceProvider {
|
||||
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
|
||||
/*
|
||||
* Bootstrap the application service
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__ . '/../config/pdf.php' => config_path('pdf.php'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__ . '/../config/pdf.php', 'pdf'
|
||||
);
|
||||
|
||||
$this->app->bind('mpdf.wrapper', function($app) {
|
||||
return new PdfWrapper();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array('mpdf.pdf');
|
||||
}
|
||||
|
||||
}
|
||||
45
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/PdfWrapper.php
vendored
Normal file
45
vendor/niklasravnsborg/laravel-pdf/src/LaravelPdf/PdfWrapper.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace niklasravnsborg\LaravelPdf;
|
||||
|
||||
use File;
|
||||
use View;
|
||||
|
||||
class PdfWrapper {
|
||||
|
||||
/**
|
||||
* Load a HTML string
|
||||
*
|
||||
* @param string $html
|
||||
* @return Pdf
|
||||
*/
|
||||
public function loadHTML($html, $config = [])
|
||||
{
|
||||
return new Pdf($html, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a HTML file
|
||||
*
|
||||
* @param string $file
|
||||
* @return Pdf
|
||||
*/
|
||||
public function loadFile($file, $config = [])
|
||||
{
|
||||
return new Pdf(File::get($file), $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a View and convert to HTML
|
||||
*
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return Pdf
|
||||
*/
|
||||
public function loadView($view, $data = [], $mergeData = [], $config = [])
|
||||
{
|
||||
return new Pdf(View::make($view, $data, $mergeData)->render(), $config);
|
||||
}
|
||||
|
||||
}
|
||||
15
vendor/niklasravnsborg/laravel-pdf/src/config/pdf.php
vendored
Normal file
15
vendor/niklasravnsborg/laravel-pdf/src/config/pdf.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'mode' => 'utf-8',
|
||||
'format' => 'A4',
|
||||
'author' => '',
|
||||
'subject' => '',
|
||||
'keywords' => '',
|
||||
'creator' => 'Laravel Pdf',
|
||||
'display_mode' => 'fullpage',
|
||||
'tempDir' => base_path('../temp/'),
|
||||
'pdf_a' => false,
|
||||
'pdf_a_auto' => false,
|
||||
'icc_profile_path' => ''
|
||||
];
|
||||
5
vendor/niklasravnsborg/laravel-pdf/src/mpdf_ttfonts_config.php
vendored
Normal file
5
vendor/niklasravnsborg/laravel-pdf/src/mpdf_ttfonts_config.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
define('_MPDF_SYSTEM_TTFONTS', Config::get('pdf.custom_font_path'));
|
||||
$this->fontdata = array_merge($this->fontdata, Config::get('pdf.custom_font_data'));
|
||||
Reference in New Issue
Block a user