Файловый менеджер - Редактировать - /home/clickysoft/public_html/jmapi5.clickysoft.net/barryvdh.tar
Назад
laravel-dompdf/readme.md 0000644 00000011551 15021223503 0011214 0 ustar 00 ## DOMPDF Wrapper for Laravel ### Laravel wrapper for [Dompdf HTML to PDF Converter](https://github.com/dompdf/dompdf) [](https://github.com/barryvdh/laravel-dompdf/actions) [](http://choosealicense.com/licenses/mit/) [](https://packagist.org/packages/barryvdh/laravel-dompdf) [](https://packagist.org/packages/barryvdh/laravel-dompdf) [](https://fruitcake.nl/) ## Installation ### Laravel Require this package in your composer.json and update composer. This will download the package and the dompdf + fontlib libraries also. composer require barryvdh/laravel-dompdf ### Lumen After updating composer add the following lines to register provider in `bootstrap/app.php` ``` $app->register(\Barryvdh\DomPDF\ServiceProvider::class); ``` To change the configuration, copy the config file to your config folder and enable it in `bootstrap/app.php`: ``` $app->configure('dompdf'); ``` ## Using You can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download. ```php use Barryvdh\DomPDF\Facade\Pdf; $pdf = Pdf::loadView('pdf.invoice', $data); return $pdf->download('invoice.pdf'); ``` or use the App container: ```php $pdf = App::make('dompdf.wrapper'); $pdf->loadHTML('<h1>Test</h1>'); return $pdf->stream(); ``` Or use the facade: You can chain the methods: ```php return Pdf::loadFile(public_path().'/myfile.html')->save('/path-to/my_stored_file.pdf')->stream('download.pdf'); ``` You can change the orientation and paper size, and hide or show errors (by default, errors are shown when debug is on) ```php Pdf::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('myfile.pdf') ``` If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself. Use `php artisan vendor:publish` to create a config file located at `config/dompdf.php` which will allow you to define local configurations to change some settings (default paper etc). You can also use your ConfigProvider to set certain keys. ### Configuration The defaults configuration settings are set in `config/dompdf.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command: ```shell php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider" ``` You can still alter the dompdf options in your code before generating the pdf using this command: ```php Pdf::setOption(['dpi' => 150, 'defaultFont' => 'sans-serif']); ``` Available options and their defaults: * __rootDir__: "{app_directory}/vendor/dompdf/dompdf" * __tempDir__: "/tmp" _(available in config/dompdf.php)_ * __fontDir__: "{app_directory}/storage/fonts" _(available in config/dompdf.php)_ * __fontCache__: "{app_directory}/storage/fonts" _(available in config/dompdf.php)_ * __chroot__: "{app_directory}" _(available in config/dompdf.php)_ * __logOutputFile__: "/tmp/log.htm" * __defaultMediaType__: "screen" _(available in config/dompdf.php)_ * __defaultPaperSize__: "a4" _(available in config/dompdf.php)_ * __defaultFont__: "serif" _(available in config/dompdf.php)_ * __dpi__: 96 _(available in config/dompdf.php)_ * __fontHeightRatio__: 1.1 _(available in config/dompdf.php)_ * __isPhpEnabled__: false _(available in config/dompdf.php)_ * __isRemoteEnabled__: true _(available in config/dompdf.php)_ * __isJavascriptEnabled__: true _(available in config/dompdf.php)_ * __isHtml5ParserEnabled__: false _(available in config/dompdf.php)_ * __isFontSubsettingEnabled__: false _(available in config/dompdf.php)_ * __debugPng__: false * __debugKeepTemp__: false * __debugCss__: false * __debugLayout__: false * __debugLayoutLines__: true * __debugLayoutBlocks__: true * __debugLayoutInline__: true * __debugLayoutPaddingBox__: true * __pdfBackend__: "CPDF" _(available in config/dompdf.php)_ * __pdflibLicense__: "" * __adminUsername__: "user" * __adminPassword__: "password" ### Tip: UTF-8 support In your templates, set the UTF-8 Metatag: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ### Tip: Page breaks You can use the CSS `page-break-before`/`page-break-after` properties to create a new page. <style> .page-break { page-break-after: always; } </style> <h1>Page 1</h1> <div class="page-break"></div> <h1>Page 2</h1> ### License This DOMPDF Wrapper for Laravel is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) laravel-dompdf/composer.json 0000644 00000003111 15021223503 0012150 0 ustar 00 { "name": "barryvdh/laravel-dompdf", "description": "A DOMPDF Wrapper for Laravel", "license": "MIT", "keywords": [ "laravel", "dompdf", "pdf" ], "authors": [ { "name": "Barry vd. Heuvel", "email": "barryvdh@gmail.com" } ], "require": { "php": "^7.2 || ^8.0", "dompdf/dompdf": "^2.0.7", "illuminate/support": "^6|^7|^8|^9|^10|^11" }, "require-dev": { "orchestra/testbench": "^4|^5|^6|^7|^8|^9", "squizlabs/php_codesniffer": "^3.5", "phpro/grumphp": "^1 || ^2.5", "larastan/larastan": "^1.0|^2.7.0" }, "autoload": { "psr-4": { "Barryvdh\\DomPDF\\": "src" } }, "autoload-dev": { "psr-4": { "Barryvdh\\DomPDF\\Tests\\": "tests" } }, "extra": { "branch-alias": { "dev-master": "2.0-dev" }, "laravel": { "providers": [ "Barryvdh\\DomPDF\\ServiceProvider" ], "aliases": { "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf", "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf" } } }, "scripts": { "test": "phpunit", "check-style": "phpcs -p --standard=psr12 src/", "fix-style": "phpcbf -p --standard=psr12 src/", "phpstan": "phpstan analyze --memory-limit=-1" }, "minimum-stability": "dev", "prefer-stable": true, "config": { "allow-plugins": { "phpro/grumphp": true } } } laravel-dompdf/CHANGELOG.md 0000644 00000003235 15021223503 0011246 0 ustar 00 # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [2.0.0-beta3] ### Changed - Remove the deprecated class 'Barryvdh\DomPDF\Facade' Facade in favor of Barryvdh\DomPDF\Facade\Pdf - Set default Facade to Pdf instead of PDF ## [2.0.0-beta2] ### Added - Upgraded to use dompdf/dompdf 2.x - `setOption` to change only the specified option(s), instead of replace all options. - Magic methods to allow calls to Dompdf methods easier. (#892) - `default_paper_orientation` option has been added to the defaults. - Add option to set public path (#890) ### Changed - HTML5 parser option is deprecated, because this is always on. - `orientation` option was never used. Removed in favor of `options.default_paper_orientation` ### Deprecated - `setOptions` is now deprecated. Use `setOption` instead. - Config `dompdf.defines` has been renamed to `dompdf.options` ## Dompdf 2.0.0, highlights since 1.2.x > https://github.com/dompdf/dompdf/releases/tag/v2.0.0 > - Addresses multiple security vulnerabilities (see link) > - Modifies callback and page_script/page_text handling (breaking change, see link) > - Switches the HTML5 parser to Masterminds/HTML5 > - Improves CSS property parsing and representation > - Improves border, outline, and background rendering for inline elements > - Switches installed fonts and font metrics cache file format to JSON > - Adds support for the inset CSS shorthand property and the legacy break-word keyword for word-break > - Adds "end_document" callback event laravel-dompdf/config/dompdf.php 0000644 00000026324 15021223503 0012670 0 ustar 00 <?php return array( /* |-------------------------------------------------------------------------- | Settings |-------------------------------------------------------------------------- | | Set some default values. It is possible to add all defines that can be set | in dompdf_config.inc.php. You can also override the entire config file. | */ 'show_warnings' => false, // Throw an Exception on warnings from dompdf 'public_path' => null, // Override the public path if needed /* * Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £. */ 'convert_entities' => true, 'options' => array( /** * The location of the DOMPDF font directory * * The location of the directory where DOMPDF will store fonts and font metrics * Note: This directory must exist and be writable by the webserver process. * *Please note the trailing slash.* * * Notes regarding fonts: * Additional .afm font metrics can be added by executing load_font.php from command line. * * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must * be embedded in the pdf file or the PDF may not display correctly. This can significantly * increase file size unless font subsetting is enabled. Before embedding a font please * review your rights under the font license. * * Any font specification in the source HTML is translated to the closest font available * in the font directory. * * The pdf standard "Base 14 fonts" are: * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique, * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique, * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic, * Symbol, ZapfDingbats. */ "font_dir" => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782) /** * The location of the DOMPDF font cache directory * * This directory contains the cached font metrics for the fonts used by DOMPDF. * This directory can be the same as DOMPDF_FONT_DIR * * Note: This directory must exist and be writable by the webserver process. */ "font_cache" => storage_path('fonts'), /** * The location of a temporary directory. * * The directory specified must be writeable by the webserver process. * The temporary directory is required to download remote images and when * using the PDFLib back end. */ "temp_dir" => sys_get_temp_dir(), /** * ==== IMPORTANT ==== * * dompdf's "chroot": Prevents dompdf from accessing system files or other * files on the webserver. All local files opened by dompdf must be in a * subdirectory of this directory. DO NOT set it to '/' since this could * allow an attacker to use dompdf to read any files on the server. This * should be an absolute path. * This is only checked on command line call by dompdf.php, but not by * direct class use like: * $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output(); */ "chroot" => realpath(base_path()), /** * Protocol whitelist * * Protocols and PHP wrappers allowed in URIs, and the validation rules * that determine if a resouce may be loaded. Full support is not guaranteed * for the protocols/wrappers specified * by this array. * * @var array */ 'allowed_protocols' => [ "file://" => ["rules" => []], "http://" => ["rules" => []], "https://" => ["rules" => []] ], /** * @var string */ 'log_output_file' => null, /** * Whether to enable font subsetting or not. */ "enable_font_subsetting" => false, /** * The PDF rendering backend to use * * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link * Canvas_Factory} ultimately determines which rendering class to instantiate * based on this setting. * * Both PDFLib & CPDF rendering backends provide sufficient rendering * capabilities for dompdf, however additional features (e.g. object, * image and font support, etc.) differ between backends. Please see * {@link PDFLib_Adapter} for more information on the PDFLib backend * and {@link CPDF_Adapter} and lib/class.pdf.php for more information * on CPDF. Also see the documentation for each backend at the links * below. * * The GD rendering backend is a little different than PDFLib and * CPDF. Several features of CPDF and PDFLib are not supported or do * not make any sense when creating image files. For example, * multiple pages are not supported, nor are PDF 'objects'. Have a * look at {@link GD_Adapter} for more information. GD support is * experimental, so use it at your own risk. * * @link http://www.pdflib.com * @link http://www.ros.co.nz/pdf * @link http://www.php.net/image */ "pdf_backend" => "CPDF", /** * PDFlib license key * * If you are using a licensed, commercial version of PDFlib, specify * your license key here. If you are using PDFlib-Lite or are evaluating * the commercial version of PDFlib, comment out this setting. * * @link http://www.pdflib.com * * If pdflib present in web server and auto or selected explicitely above, * a real license code must exist! */ //"DOMPDF_PDFLIB_LICENSE" => "your license key here", /** * html target media view which should be rendered into pdf. * List of types and parsing rules for future extensions: * http://www.w3.org/TR/REC-html40/types.html * screen, tty, tv, projection, handheld, print, braille, aural, all * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3. * Note, even though the generated pdf file is intended for print output, * the desired content might be different (e.g. screen or projection view of html file). * Therefore allow specification of content here. */ "default_media_type" => "screen", /** * The default paper size. * * North America standard is "letter"; other countries generally "a4" * * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.) */ "default_paper_size" => "a4", /** * The default paper orientation. * * The orientation of the page (portrait or landscape). * * @var string */ 'default_paper_orientation' => "portrait", /** * The default font family * * Used if no suitable fonts can be found. This must exist in the font folder. * @var string */ "default_font" => "serif", /** * Image DPI setting * * This setting determines the default DPI setting for images and fonts. The * DPI may be overridden for inline images by explictly setting the * image's width & height style attributes (i.e. if the image's native * width is 600 pixels and you specify the image's width as 72 points, * the image will have a DPI of 600 in the rendered PDF. The DPI of * background images can not be overridden and is controlled entirely * via this parameter. * * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI). * If a size in html is given as px (or without unit as image size), * this tells the corresponding size in pt. * This adjusts the relative sizes to be similar to the rendering of the * html page in a reference browser. * * In pdf, always 1 pt = 1/72 inch * * Rendering resolution of various browsers in px per inch: * Windows Firefox and Internet Explorer: * SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:? * Linux Firefox: * about:config *resolution: Default:96 * (xorg screen dimension in mm and Desktop font dpi settings are ignored) * * Take care about extra font/image zoom factor of browser. * * In images, <img> size in pixel attribute, img css style, are overriding * the real image dimension in px for rendering. * * @var int */ "dpi" => 96, /** * Enable inline PHP * * If this setting is set to true then DOMPDF will automatically evaluate * inline PHP contained within <script type="text/php"> ... </script> tags. * * Enabling this for documents you do not trust (e.g. arbitrary remote html * pages) is a security risk. Set this option to false if you wish to process * untrusted documents. * * @var bool */ "enable_php" => false, /** * Enable inline Javascript * * If this setting is set to true then DOMPDF will automatically insert * JavaScript code contained within <script type="text/javascript"> ... </script> tags. * * @var bool */ "enable_javascript" => true, /** * Enable remote file access * * If this setting is set to true, DOMPDF will access remote sites for * images and CSS files as required. * This is required for part of test case www/test/image_variants.html through www/examples.php * * Attention! * This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and * allowing remote access to dompdf.php or on allowing remote html code to be passed to * $dompdf = new DOMPDF(, $dompdf->load_html(..., * This allows anonymous users to download legally doubtful internet content which on * tracing back appears to being downloaded by your server, or allows malicious php code * in remote html pages to be executed by your server with your account privileges. * * @var bool */ "enable_remote" => true, /** * A ratio applied to the fonts height to be more like browsers' line height */ "font_height_ratio" => 1.1, /** * Use the HTML5 Lib parser * * @deprecated This feature is now always on in dompdf 2.x * @var bool */ "enable_html5_parser" => true, ), ); laravel-dompdf/src/Facade/Pdf.php 0000644 00000005017 15021223503 0012611 0 ustar 00 <?php namespace Barryvdh\DomPDF\Facade; use Barryvdh\DomPDF\PDF as BasePDF; use Illuminate\Support\Facades\Facade as IlluminateFacade; use RuntimeException; /** * @method static BasePDF setBaseHost(string $baseHost) * @method static BasePDF setBasePath(string $basePath) * @method static BasePDF setCanvas(\Dompdf\Canvas $canvas) * @method static BasePDF setCallbacks(array $callbacks) * @method static BasePDF setCss(\Dompdf\Css\Stylesheet $css) * @method static BasePDF setDefaultView(string $defaultView, array $options) * @method static BasePDF setDom(\DOMDocument $dom) * @method static BasePDF setFontMetrics(\Dompdf\FontMetrics $fontMetrics) * @method static BasePDF setHttpContext(resource|array $httpContext) * @method static BasePDF setPaper(string|float[] $paper, string $orientation = 'portrait') * @method static BasePDF setProtocol(string $protocol) * @method static BasePDF setTree(\Dompdf\Frame\FrameTree $tree) * @method static BasePDF setWarnings(bool $warnings) * @method static BasePDF setOption(array|string $attribute, $value = null) * @method static BasePDF setOptions(array $options) * @method static BasePDF loadView(string $view, array $data = [], array $mergeData = [], ?string $encoding = null) * @method static BasePDF loadHTML(string $string, ?string $encoding = null) * @method static BasePDF loadFile(string $file) * @method static BasePDF addInfo(array $info) * @method static string output(array $options = []) * @method static BasePDF save() * @method static \Illuminate\Http\Response download(string $filename = 'document.pdf') * @method static \Illuminate\Http\Response stream(string $filename = 'document.pdf') */ class Pdf extends IlluminateFacade { /** * Get the registered name of the component. * * @return string */ protected static function getFacadeAccessor() { return 'dompdf.wrapper'; } /** * Handle dynamic, static calls to the object. * * @param string $method * @param array<mixed> $args * @return mixed * * @throws \RuntimeException */ public static function __callStatic($method, $args) { /** @var \Illuminate\Contracts\Foundation\Application|null */ $app = static::getFacadeApplication(); if (! $app) { throw new RuntimeException('Facade application has not been set.'); } // Resolve a new instance, avoid using a cached instance $instance = $app->make(static::getFacadeAccessor()); return $instance->$method(...$args); } } laravel-dompdf/src/ServiceProvider.php 0000644 00000005004 15021223503 0014044 0 ustar 00 <?php namespace Barryvdh\DomPDF; use Dompdf\Dompdf; use Exception; use Illuminate\Support\Str; use Illuminate\Support\ServiceProvider as IlluminateServiceProvider; class ServiceProvider extends IlluminateServiceProvider { /** * Indicates if loading of the provider is deferred. * * @var bool */ protected $defer = false; /** * Register the service provider. * * @throws \Exception * @return void */ public function register(): void { $configPath = __DIR__ . '/../config/dompdf.php'; $this->mergeConfigFrom($configPath, 'dompdf'); $this->app->bind('dompdf.options', function ($app) { $defines = $app['config']->get('dompdf.defines'); if ($defines) { $options = []; /** * @var string $key * @var mixed $value */ foreach ($defines as $key => $value) { $key = strtolower(str_replace('DOMPDF_', '', $key)); $options[$key] = $value; } } else { $options = $app['config']->get('dompdf.options'); } return $options; }); $this->app->bind('dompdf', function ($app) { $options = $app->make('dompdf.options'); $dompdf = new Dompdf($options); $path = realpath($app['config']->get('dompdf.public_path') ?: base_path('public')); if ($path === false) { throw new \RuntimeException('Cannot resolve public path'); } $dompdf->setBasePath($path); return $dompdf; }); $this->app->alias('dompdf', Dompdf::class); $this->app->bind('dompdf.wrapper', function ($app) { return new PDF($app['dompdf'], $app['config'], $app['files'], $app['view']); }); } /** * Check if package is running under Lumen app */ protected function isLumen(): bool { return Str::contains($this->app->version(), 'Lumen') === true; } public function boot(): void { if (! $this->isLumen()) { $configPath = __DIR__ . '/../config/dompdf.php'; $this->publishes([$configPath => config_path('dompdf.php')], 'config'); } } /** * Get the services provided by the provider. * * @return array<string> */ public function provides(): array { return ['dompdf', 'dompdf.options', 'dompdf.wrapper']; } } laravel-dompdf/src/PDF.php 0000644 00000020600 15021223503 0011341 0 ustar 00 <?php namespace Barryvdh\DomPDF; use Dompdf\Adapter\CPDF; use Dompdf\Dompdf; use Dompdf\Options; use Exception; use Illuminate\Filesystem\Filesystem; use Illuminate\Contracts\View\Factory as ViewFactory; use Illuminate\Contracts\Config\Repository as ConfigRepository; use Illuminate\Http\Response; use Illuminate\Support\Facades\Storage; /** * A Laravel wrapper for Dompdf * * @package laravel-dompdf * @author Barry vd. Heuvel * * @method PDF setBaseHost(string $baseHost) * @method PDF setBasePath(string $basePath) * @method PDF setCanvas(\Dompdf\Canvas $canvas) * @method PDF setCallbacks(array $callbacks) * @method PDF setCss(\Dompdf\Css\Stylesheet $css) * @method PDF setDefaultView(string $defaultView, array $options) * @method PDF setDom(\DOMDocument $dom) * @method PDF setFontMetrics(\Dompdf\FontMetrics $fontMetrics) * @method PDF setHttpContext(resource|array $httpContext) * @method PDF setPaper(string|float[] $paper, string $orientation = 'portrait') * @method PDF setProtocol(string $protocol) * @method PDF setTree(\Dompdf\Frame\FrameTree $tree) * @method string getBaseHost() * @method string getBasePath() * @method \Dompdf\Canvas getCanvas() * @method array getCallbacks() * @method \Dompdf\Css\Stylesheet getCss() * @method \DOMDocument getDom() * @method \Dompdf\FontMetrics getFontMetrics() * @method resource getHttpContext() * @method Options getOptions() * @method \Dompdf\Frame\FrameTree getTree() * @method string getPaperOrientation() * @method float[] getPaperSize() * @method string getProtocol() */ class PDF { /** @var Dompdf */ protected $dompdf; /** @var \Illuminate\Contracts\Config\Repository */ protected $config; /** @var \Illuminate\Filesystem\Filesystem */ protected $files; /** @var \Illuminate\Contracts\View\Factory */ protected $view; /** @var bool */ protected $rendered = false; /** @var bool */ protected $showWarnings; /** @var string */ protected $public_path; public function __construct(Dompdf $dompdf, ConfigRepository $config, Filesystem $files, ViewFactory $view) { $this->dompdf = $dompdf; $this->config = $config; $this->files = $files; $this->view = $view; $this->showWarnings = $this->config->get('dompdf.show_warnings', false); } /** * Get the DomPDF instance */ public function getDomPDF(): Dompdf { return $this->dompdf; } /** * Show or hide warnings */ public function setWarnings(bool $warnings): self { $this->showWarnings = $warnings; return $this; } /** * Load a HTML string * * @param string|null $encoding Not used yet */ public function loadHTML(string $string, ?string $encoding = null): self { $string = $this->convertEntities($string); $this->dompdf->loadHtml($string, $encoding); $this->rendered = false; return $this; } /** * Load a HTML file */ public function loadFile(string $file): self { $this->dompdf->loadHtmlFile($file); $this->rendered = false; return $this; } /** * Add metadata info * @param array<string, string> $info */ public function addInfo(array $info): self { foreach ($info as $name => $value) { $this->dompdf->add_info($name, $value); } return $this; } /** * Load a View and convert to HTML * @param array<string, mixed> $data * @param array<string, mixed> $mergeData * @param string|null $encoding Not used yet */ public function loadView(string $view, array $data = [], array $mergeData = [], ?string $encoding = null): self { $html = $this->view->make($view, $data, $mergeData)->render(); return $this->loadHTML($html, $encoding); } /** * Set/Change an option (or array of options) in Dompdf * * @param array<string, mixed>|string $attribute * @param null|mixed $value */ public function setOption($attribute, $value = null): self { $this->dompdf->getOptions()->set($attribute, $value); return $this; } /** * Replace all the Options from DomPDF * * @param array<string, mixed> $options */ public function setOptions(array $options, bool $mergeWithDefaults = false): self { if ($mergeWithDefaults) { $options = array_merge(app()->make('dompdf.options'), $options); } $this->dompdf->setOptions(new Options($options)); return $this; } /** * Output the PDF as a string. * * The options parameter controls the output. Accepted options are: * * 'compress' = > 1 or 0 - apply content stream compression, this is * on (1) by default * * @param array<string, int> $options * * @return string The rendered PDF as string */ public function output(array $options = []): string { if (!$this->rendered) { $this->render(); } return (string) $this->dompdf->output($options); } /** * Save the PDF to a file */ public function save(string $filename, string $disk = null): self { $disk = $disk ?: $this->config->get('dompdf.disk'); if (! is_null($disk)) { Storage::disk($disk)->put($filename, $this->output()); return $this; } $this->files->put($filename, $this->output()); return $this; } /** * Make the PDF downloadable by the user */ public function download(string $filename = 'document.pdf'): Response { $output = $this->output(); return new Response($output, 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $filename . '"', 'Content-Length' => strlen($output), ]); } /** * Return a response with the PDF to show in the browser */ public function stream(string $filename = 'document.pdf'): Response { $output = $this->output(); return new Response($output, 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="' . $filename . '"', ]); } /** * Render the PDF */ public function render(): void { $this->dompdf->render(); if ($this->showWarnings) { global $_dompdf_warnings; if (!empty($_dompdf_warnings) && count($_dompdf_warnings)) { $warnings = ''; foreach ($_dompdf_warnings as $msg) { $warnings .= $msg . "\n"; } // $warnings .= $this->dompdf->get_canvas()->get_cpdf()->messages; if (!empty($warnings)) { throw new Exception($warnings); } } } $this->rendered = true; } /** @param array<string> $pc */ public function setEncryption(string $password, string $ownerpassword = '', array $pc = []): void { $this->render(); $canvas = $this->dompdf->getCanvas(); if (! $canvas instanceof CPDF) { throw new \RuntimeException('Encryption is only supported when using CPDF'); } $canvas->get_cpdf()->setEncryption($password, $ownerpassword, $pc); } protected function convertEntities(string $subject): string { if (false === $this->config->get('dompdf.convert_entities', true)) { return $subject; } $entities = [ '€' => '€', '£' => '£', ]; foreach ($entities as $search => $replace) { $subject = str_replace($search, $replace, $subject); } return $subject; } /** * Dynamically handle calls into the dompdf instance. * * @param string $method * @param array<mixed> $parameters * @return $this|mixed */ public function __call($method, $parameters) { if (method_exists($this, $method)) { return $this->$method(...$parameters); } if (method_exists($this->dompdf, $method)) { $return = $this->dompdf->$method(...$parameters); return $return == $this->dompdf ? $this : $return; } throw new \UnexpectedValueException("Method [{$method}] does not exist on PDF instance."); } } laravel-dompdf/LICENSE 0000644 00000002051 15021223503 0010435 0 ustar 00 MIT License Copyright (c) 2021 barryvdh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка