DOMPDF module for Laravel 5

Overview

pdf-laravel5

DOMPDF module for Laravel 5. Export your views as PDFs - with css support.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Instalation

Add:

"vsmoraes/laravel-pdf": "^2.0"

To your composer.json

or Run:

composer require vsmoraes/laravel-pdf

Then add:

Vsmoraes\Pdf\PdfServiceProvider::class

To the providers array on your config/app.php

And

'PDF' => 'Vsmoraes\Pdf\PdfFacade',

To the aliases array on yout config/app.php in order to enable the PDF facade

Usage

Route::get('/pdf/view', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)->show();
});

Force download

Route::get('/pdf/download', function() {
    $html = view('pdfs.example')->render();

    return PDF::load($html)->download();
});

Return PDF as string

Route::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 file

Route::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();
    }
}

Configuration

Dompdf 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

Comments
  • Image not found or type unknown

    Image not found or type unknown

    Hi, I am using the example which is in github, but the images are not aparecendeo always get this message "Image not found or type unknown".

    I'm trying to images of type png and jpg

    opened by sk8sta13 13
  • "Not Instantiable"

    BindingResolutionException in Container.php line 785: Target [Vsmoraes\Pdf\Pdf] is not instantiable.

    The package was just working until I updated composer, never worked since.

    opened by richardtorres314 4
  • download() ignoring filename

    download() ignoring filename

    Laravel Framework version 5.2.7 Since the last "pdf-laravel5" update from 2015-01-11, the download() method ignores the filename() method and stores every pdf as "dompdf_out.pdf"

    $html = view('invoice')->render();
    
    // DOWNLOAD
    return \PDF::load($html)
        ->filename('newFilename.pdf')
        ->download();
    
    bug 
    opened by r-pascal 3
  • output() method not working

    output() method not working

    Laravel Framework version 5.2.6 show() and download() methods working fine, so setup shouldn't be the problem. Trying to store the pdf on the filesystem returns no error, but the file is not stored on the filesystem.

    $html = view('invoice', compact('invoice'))->render();
    
    $result = \PDF::load($html)
                ->filename(storage_path('app/invoices/inv-123.pdf'))
                ->output();
    
    bug 
    opened by r-pascal 2
  • Constant DOMPDF_ENABLE_AUTOLOAD already defined

    Constant DOMPDF_ENABLE_AUTOLOAD already defined

    I'd like to use Vsmoraes\Pdf\Pdf in several places, but i catch an error "Constant DOMPDF_ENABLE_AUTOLOAD already defined"

    As i see, code in your Vsmoraes\Pdf\PdfServiceProvider should be like this: defined('DOMPDF_ENABLE_AUTOLOAD') || define('DOMPDF_ENABLE_AUTOLOAD', false); instead of define('DOMPDF_ENABLE_AUTOLOAD', false);

    And i think, it will be a good idea to bind Vsmoraes\Pdf\Pdf as shared.

    opened by Aeliot-Tm 1
  • Maximum Time out Exceed

    Maximum Time out Exceed

    Really confuse when I try to export HTML to PDF alwyas got this exception

    FatalErrorException in functions.inc.php line 859: Maximum execution time of 60 seconds exceeded

    It only work when I try just load really simple HTML like <html>Hello</html>

    But when try the complex one which is use blade for templating doesn't work out. This is how I try to export to PDF $html = view("/grid-barcode")->with('data',$data)->render(); return PDF::load($html)->download();

    Then i get this. image

    Please solve this issue Thank you

    opened by Arakh 1
  • Does not allow for multiple PDF generation in a single request.

    Does not allow for multiple PDF generation in a single request.

    When generating multiple PDF's in a single request I get the following error message on the 2nd attempt to generate the PDF.

    DOMPDF_Exception in inline_positioner.cls.php line 37:
    No block-level parent found. Not good.
    

    It appears that the PDF object is only able to create a single PDF per request.

    Unfortunately the PDF object is only instantiated when the service provider is registered and theres doesn't seem to be anyway way to re-isntatantiate the DOMPDF object at runtime. Is it possible to provide an additional method to create a new instantiation of DOMPDF? Could the current instance be unset and new instance created with a new method?

    opened by mgwoolf 1
  • Class 'Vsmoraes\Pdf\PdfServiceProvider' not found

    Class 'Vsmoraes\Pdf\PdfServiceProvider' not found

    I have installed this package at windows local server working fine when im doing live at linux shared hosting it is showing this error

    FatalErrorException in ProviderRepository.php line 146: Class 'Vsmoraes\Pdf\PdfServiceProvider' not found

    app.php Vsmoraes\Pdf\PdfServiceProvider::class, ///provider 'PDF' => 'Vsmoraes\Pdf\PdfFacade', //aliases

    in vendor folder vsmoraes/laravel-pdf/src/..... ///all files

    Please let me what is the issue at linux.

    opened by shafqatjan 1
  • How can i load dynamic view with the source form database

    How can i load dynamic view with the source form database

    I'm passing the $cv_info to view to show dynamic result.But it's said

    Undefined variable: cv_info (View: D:\xampp\htdocs\FreelancerJob\resources\views\ui\UserInfo\viewCV.blade.php)

    Here is my controller

    $cv_info=CV::where('id','=',$cv_id)->first();
            $html = view('ui.userinfo.viewCV',$cv_info)->render();
    
            return $this->pdf
            ->load($html)
            ->show();
    

    How can i fix it.Thanks for your help

    opened by ngohungphuc 1
  • can not support genernate unicode pdf

    can not support genernate unicode pdf

    can not support genernate unicode pdf. For example the Chinese , the reason is the font did not support. But i have try to use dompdf load_font.php to install font ,but fail.

    PHP Fatal error: require_once(): Failed opening required '/home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/../vendor/phenx/php-font-lib/classes/Font.php"' (include_path='.:/usr/share/php:/usr/share/pear') in /home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/dompdf_config.inc.php on line 333 PHP Stack trace: PHP 1. {main}() /home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/load_font.php:0 PHP 2. require_once() /home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/load_font.php:11

    Fatal error: require_once(): Failed opening required '/home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/../vendor/phenx/php-font-lib/classes/Font.php"' (include_path='.:/usr/share/php:/usr/share/pear') in /home/vagrant/Code/PersonalInfoPushCenter/vendor/dompdf/dompdf/dompdf_config.inc.php on line 333

    opened by LiangJianle 1
  • Title doesn't display properly

    Title doesn't display properly

    Is there anyway to have the title display the text of the title rather than the route? My title tags don't seem to be working no matter where they're placed. Thank you!

    opened by richardtorres314 1
  • cannot update

    cannot update

    hi there, im using pdf-laravel5 version 1.0.3. i tried to update to latest version but my composer give message nothing to update and install. how can i fix it?

    opened by shahiran250890 0
  • Not Working For Large Content HTML in AWS

    Not Working For Large Content HTML in AWS

    This Library is working fine in My Localhost. But When I push Code to My AWS Server, It is working fine for small contents but not working for big contents. Any Idea to Fix This.

    I use Like,

    return PDF::load($html)->download();

    Please Help Me.

    opened by darpan55 0
  • Generating multiple pdf using foreach

    Generating multiple pdf using foreach

    DOMPDF_Exception in inline_positioner.cls.php line 37: No block-level parent found. Not good.

    Please let me know if some solution is there for this issue. I am getting this error while generating multiple pdf together using foreach in laravel 5.0.

    Thanks in advance Neeteesh Mishra

    opened by Neeteesh 0
Releases(2.0)
Owner
Vinicius Moraes
Spectator of a world in ruins
Vinicius Moraes
A DOMPDF Wrapper for Laravel

DOMPDF Wrapper for Laravel Laravel wrapper for Dompdf HTML to PDF Converter Require this package in your composer.json and update composer. This will

Barry vd. Heuvel 5.6k Jan 7, 2023
Magento 2 Module for creating PDF's based on wkhtmltopdf

Magento 2 PDF generator Magento 2 module to ease the pdf generation using wkhtmltopdf features Installation composer require "staempfli/magento2-modul

Stämpfli AG 56 Jul 7, 2022
Laravel Snappy PDF

Snappy PDF/Image Wrapper for Laravel 5 and Lumen 5.1 This package is a ServiceProvider for Snappy: https://github.com/KnpLabs/snappy. Wkhtmltopdf Inst

Barry vd. Heuvel 2.3k Jan 2, 2023
Adobe XDでデザインしてSVGでエクスポートしたテンプレートをもとに、A4サイズの帳票をHTMLで出力する機能のPHP(Laravel)による実装例です

svg-paper-example Adobe XDでデザインしてSVGでエクスポートしたテンプレートをもとに、A4サイズの帳票をHTMLで出力する機能のPHP(Laravel)による実装例です。 こちらで実際に動くデモが見られます ?? 実装内容についての詳細は こちらのブログ記事 で解説していま

Takashi Kanemoto 21 Dec 11, 2022
Generate PDFs in Laravel with Mpdf.

Laravel Mpdf: Using Mpdf in Laravel for generate Pdfs Easily generate PDF documents from HTML right inside of Laravel using this mpdf wrapper. Importa

Carlos Meneses 264 Jan 4, 2023
A Laravel package for creating PDF files using LaTeX

LaraTeX A laravel package to generate PDFs using LaTeX · Report Bug · Request Feature For better visualization you can find a small Demo and the HTML

Ismael Wismann 67 Dec 28, 2022
Generate PDF invoices for your customers in laravel

What is Invoices? Invoices is a Laravel library that generates a PDF invoice for your customers. The PDF can be either downloaded or streamed in the b

Erik C. Forés 399 Jan 2, 2023
Rapidly Generate Simple Pdf, CSV, & Excel Report Package on Laravel

Laravel Report Generators (PDF, CSV & Excel) Rapidly Generate Simple Pdf Report on Laravel (Using barryvdh/laravel-dompdf or barryvdh/laravel-snappy)

Jimmy Setiawan 513 Dec 31, 2022
Laravel package to convert HTML to PDF, supporting multiple drivers.

eve/pdf-converter A Laravel package to help convert HTML to PDF. Supports multiple drivers. Requirements and Installation eve/pdf-converter requires L

eve.io 11 Feb 15, 2022
⚡️ MIRROR — A feature-rich Laravel wrapper for the WeasyPrint Document Factory.

WeasyPrint for Laravel A feature-rich Laravel wrapper for the WeasyPrint Document Factory. This package requires Laravel 8.47+ running on PHP 8+ in or

Mike Rockétt 7 Dec 30, 2022
Browsershot wrapper for Laravel 5

Browsershot wrapper for Laravel 5 This package takes advantage of Google Chrome's Headless mode to take screenshots and generate PDFs from websites, v

VECO 108 Jul 25, 2022
Ce projet vous montre comment utiliser des fonts localement dans vos applications Laravel, avec ViteJS et Tailwind CSS

Laravel - use local fonts with Tailwind CSS and Vite Ce projet est né d'un constat: vous êtes souvent nombreuses et nombreux à galérer pour utiliser d

Fred Christian 2 Sep 20, 2022
DOMPDF module for Laravel 5

pdf-laravel5 DOMPDF module for Laravel 5. Export your views as PDFs - with css support. Instalation Add: "vsmoraes/laravel-pdf": "^2.0" To your compo

Vinicius Moraes 88 Jul 25, 2022
A DOMPDF Wrapper for Laravel

DOMPDF Wrapper for Laravel Laravel wrapper for Dompdf HTML to PDF Converter Require this package in your composer.json and update composer. This will

Barry vd. Heuvel 5.6k Jan 7, 2023
A DOMPDF Wrapper for Laravel

DOMPDF Wrapper for Laravel Laravel wrapper for Dompdf HTML to PDF Converter Require this package in your composer.json and update composer. This will

Barry vd. Heuvel 5.6k Dec 25, 2022
The Laravel eCommerce DHL Shipping module module calculates the shipping rates based on DHL API for product shipping.

Introduction DHL Shipping Add-on provides DHL Shipping methods for shipping the product. It packs in lots of demanding features that allows your busin

Bagisto 1 May 31, 2022
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like Advanced CRUD Generation, Module Manager, Backups and many more.

LaraAdmin 1.0 LaraAdmin is a Open source CRM for quick-start Admin based applications with features like Advanced CRUD Generation, Schema Manager and

Dwij IT Solutions 1.5k Dec 29, 2022
Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app. This enables your app to not only respond to new emails but also allows it to read and parse existing mails and much more.

null 530 Jan 6, 2023
Module Management In Laravel

Laravel-Modules Laravel laravel-modules 5.4 ^1.0 5.5 ^2.0 5.6 ^3.0 5.7 ^4.0 5.8 ^5.0 6.0 ^6.0 7.0 ^7.0 8.0 ^8.0 nwidart/laravel-modules is a Laravel p

Nicolas Widart 4.6k Dec 29, 2022