Generate PDF invoices for your customers in laravel

Overview

StyleCI Status Build For Laravel Total Downloads Latest Stable Version License

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 browser. It's highly customizable and you can modify the whole output view as well.

Sample Invoice

This is a sample invoice generated using this library:

Sample Invoice

$invoice = \ConsoleTVs\Invoices\Classes\Invoice::make()
                ->addItem('Test Item', 10.25, 2, 1412)
                ->addItem('Test Item 2', 5, 2, 923)
                ->addItem('Test Item 3', 15.55, 5, 42)
                ->addItem('Test Item 4', 1.25, 1, 923)
                ->addItem('Test Item 5', 3.12, 1, 3142)
                ->addItem('Test Item 6', 6.41, 3, 452)
                ->addItem('Test Item 7', 2.86, 1, 1526)
                ->addItem('Test Item 8', 5, 2, 923, 'https://dummyimage.com/64x64/000/fff')
                ->number(4021)
                ->with_pagination(true)
                ->duplicate_header(true)
                ->due_date(Carbon::now()->addMonths(1))
                ->notes('Lrem ipsum dolor sit amet, consectetur adipiscing elit.')
                ->customer([
                    'name'      => 'Èrik Campobadal Forés',
                    'id'        => '12345678A',
                    'phone'     => '+34 123 456 789',
                    'location'  => 'C / Unknown Street 1st',
                    'zip'       => '08241',
                    'city'      => 'Manresa',
                    'country'   => 'Spain',
                ])
                ->download('demo')
                //or save it somewhere
                ->save('public/myinvoicename.pdf');

Documentation

License

MIT License

Copyright (c) 2017 Erik Campobadal

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.

Special thanks

Comments
  • Question: Subtotals and page numbers on multi-page invoices

    Question: Subtotals and page numbers on multi-page invoices

    Quick question: Are multi-page invoices properly handled? I mean, what happens if there is a large number of line items, that don't fit on a single page?

    I would expect the following:

    • Page number (x out of y) on each page
    • Subtotals on top of each page (except on first page, of course)
    • Totals only on last page
    • Optional header/footer on consecutive pages

    Thanks a lot!

    enhancement 
    opened by jsphpl 10
  • dompdf is slow as hell

    dompdf is slow as hell

    The big issue with dompdf is that it is slow as hell on bigger installations and images. Rendering an invoice takes about 30 seconds per page. (Logo and a bootstrap table)

    As you are using a single Class file where you do the actual PDF it shouldn't be a big deal adding another generator in there. I'm currently evaluating a few choices to see which ones actually improve speed.

    enhancement help wanted easy 
    opened by ToeiRei 8
  • How to get two pages in a document

    How to get two pages in a document

    Hi, I was trying to generate pages in the same document, but I don't know how to go about doing this. I have tried using two make();but it didn't work is there any fix you can offer

    opened by david-saint 7
  • Add default value for the new custom template

    Add default value for the new custom template

    The addition of that template variable to specify a custom template broke PDF generation for anyone who already had this package in use, since we didn't expect to have to specify a template.

    image

    This PR seeks to set a sensible default for that variable based on the previously recommend location of the default invoices template.

    opened by jkudish 6
  • Laravel : impossible to use custom template

    Laravel : impossible to use custom template

    Great lib, but I've encountered on a problem that putting custom template is impossible since blade lookup only happens within library scope. edit: current workaround is to clone PHP class into project and pass to it name of template (since class is in project scope, it works just fine ;)

    opened by marecektn 6
  • How define Tax or no Tax per invoice

    How define Tax or no Tax per invoice

    I have a requirement to generate invoices with and without VAT, but I can't find the exact way to achieve this as the example does not show this.

    Do you define differnet tax rates in the config file ?

    'tax_rates' => [
        [ 'name'      => 'VAT', 'tax'       => 20, 'tax_type'  => 'percentage', ],
     [ 'name'      => 'noVAT', 'tax'       => 0, 'tax_type'  => 'percentage', ],
      ],
    

    and then when you make an invoice, how exactly do you define what tax rate to use ?

    $invoice = \ConsoleTVs\Invoices\Classes\Invoice::make()
                    ->addItem(......)
                    ->number(.....)
                   ->tax_rates('VAT') ??????????????????? or  ->tax(false) or ?????
    

    Thanks for any help anyone can provide.

    opened by martinval 5
  • Image in cell

    Image in cell

    I am testing this amazing plugin and trying to figure out if I can pass a custom argument in addItem method in order to import images in cells.

    Does anyone have implemented that?

    enhancement 
    opened by paligiannis 5
  • Multiple tax rates

    Multiple tax rates

    Is the library capable of handling different tax rates for each product? In Germany, we have two rates (7% and 19%) for different kinds of products.

    Can i show

    • the tax class for each line item on the invoice?
    • total tax amount for each class separately?

    Thanks in advance!

    enhancement help wanted 
    opened by jsphpl 5
  • large figures upset the total

    large figures upset the total

    The total price calculation breaks in here (it's something to do with bcmul) If the inputs to the method are:

    $name = 'blah';
    $price = '8,333.325';
    $ammount = 1; 
    $id = '';
    $this->decimals is the default (2)
    

    The output will return 0.00

    public function addItem($name, $price, $ammount = 1, $id = '-')
      {
          $price = number_format($price, $this->decimals);
    
          $this->items->push(Collection::make([
              'name'       => $name,
              'price'      => $price,
              'ammount'    => $ammount,
              'totalPrice' => number_format(bcmul($price, $ammount, $this->decimals), $this->decimals),
              'id'         => $id,
          ]));
    
          return $this;
      }
    
    

    BTW amount is mispelt here 😄

    opened by mbuk 5
  • Adding the due date on invoices

    Adding the due date on invoices

    The due date can be editable on each invoice. The due date can be set to null, so no due date appears on invoice. The default due date is set to 3 months.

    opened by codevio 3
  • Saving the pdf to a different disk

    Saving the pdf to a different disk

    The save() method saves it in the default disk in the Storage facade. It would be nice being able to specify which disk you want to save in a project with multiples (e.g Storage::disk('s3')...).

    I can send a PR to add an array of options to the save() method to take that in consideration (or any other better suggestions to handle this case).

    opened by edmilsonrobson 3
  • A facade root has not been set

    A facade root has not been set

    I'm getting this error:

    Type: RuntimeException

    Message: A facade root has not been set.
    
    Filename: /homepages/6/d487641550/htdocs/estaxi/vendor/illuminate/support/Facades/Facade.php
    
    Line Number: 258
    
    Backtrace:
    
    File: /homepages/6/d487641550/htdocs/estaxi/vendor/consoletvs/invoices/Classes/PDF.php
    Line: 57
    Function: __callStatic
    
    File: /homepages/6/d487641550/htdocs/estaxi/vendor/consoletvs/invoices/Classes/Invoice.php
    Line: 378
    Function: generate
    
    File: /homepages/6/d487641550/htdocs/estaxi/vendor/consoletvs/invoices/Classes/Invoice.php
    Line: 425
    Function: generate
    
    File: /homepages/6/d487641550/htdocs/estaxi/application/views/wallet/withdrawdata.php
    Line: 30
    Function: show
    

    I'm using the example code:

     $invoice = \ConsoleTVs\Invoices\Classes\Invoice::make()
                    ->addItem('Test Item', 10.25, 2, 1412)
                    ->addItem('Test Item 2', 5, 2, 923)
                    ->addItem('Test Item 3', 15.55, 5, 42)
                    ->addItem('Test Item 4', 1.25, 1, 923)
                    ->addItem('Test Item 5', 3.12, 1, 3142)
                    ->addItem('Test Item 6', 6.41, 3, 452)
                    ->addItem('Test Item 7', 2.86, 1, 1526)
                    ->addItem('Test Item 8', 5, 2, 923, 'https://dummyimage.com/64x64/000/fff')
                    ->number(4021)
                    ->with_pagination(true)
                    ->duplicate_header(true)
                    ->due_date(Carbon::now()->addMonths(1))
                    ->notes('Lrem ipsum dolor sit amet, consectetur adipiscing elit.')
                    ->customer([
                        'name'      => 'Èrik Campobadal Forés',
                        'id'        => '12345678A',
                        'phone'     => '+34 123 456 789',
                        'location'  => 'C / Unknown Street 1st',
                        'zip'       => '08241',
                        'city'      => 'Manresa',
                        'country'   => 'Spain',
                    ])
                    ->show('demo');```
    
    
    opened by ricardocaste 0
  • Add instructions to publish the vendor configuration in the documentation

    Add instructions to publish the vendor configuration in the documentation

    Description

    I want to publish the configurations files, but I did not see any command I can copy/paste to do so.

    Expected behavior

    I can see some instructions to generate and customize the configuration files.

    Actual behavior

    No instructions in the documentation to customize the configuration files.

    opened by khalyomede 0
Releases(1.8.1)
Owner
Erik C. Forés
ICT Systems Engineer. Senior developer with years of experience on the web. I build and maintain a lot of libraries, frameworks and a programming language.
Erik C. Forés
Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using Gravity Forms.

Gravity PDF Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using the pop

Gravity PDF 90 Nov 14, 2022
Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2

Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2. If you have an enabled template and a default template for the store you need your template the system will print the pdf template.

EAdesign 64 Oct 18, 2021
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
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Jan 6, 2023
Generate pdf file with printable labels

printable_labels_pdf Generate pdf file with printable labels with PHP code. CREATE A PDF FILE WITH LABELS EASELY: You can get a pdf file with labels f

Rafael Martin Soto 5 Sep 22, 2022
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Dec 26, 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
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
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
Convert HTML to PDF using Webkit (QtWebKit)

wkhtmltopdf and wkhtmltoimage wkhtmltopdf and wkhtmltoimage are command line tools to render HTML into PDF and various image formats using the QT Webk

wkhtmltopdf 13k Jan 4, 2023
HTML to PDF converter for PHP

Dompdf Dompdf is an HTML to PDF converter At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is

null 9.3k Jan 1, 2023
PHP library generating PDF files from UTF-8 encoded HTML

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF (see CREDITS), with a number of enhancement

null 3.8k Jan 2, 2023
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Snappy Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopd

KNP Labs 4.1k Dec 30, 2022
TCPDF - PHP PDF Library - https://tcpdf.org

tc-lib-pdf PHP PDF Library UNDER DEVELOPMENT (NOT READY) UPDATE: CURRENTLY ALL THE DEPENDENCY LIBRARIES ARE ALMOST COMPLETE BUT THE CORE LIBRARY STILL

Tecnick.com LTD 1.3k Dec 30, 2022
Pdf and graphic files generator library written in php

Information Examples Sample documents are in the "examples" directory. "index.php" file is the web interface to browse examples, "cli.php" is a consol

Piotr Śliwa 335 Nov 26, 2022
PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.

PdfParser Pdf Parser, a standalone PHP library, provides various tools to extract data from a PDF file. Website : https://www.pdfparser.org Test the A

Sebastien MALOT 1.9k Jan 2, 2023
Convert html to an image, pdf or string

Convert a webpage to an image or pdf using headless Chrome The package can convert a webpage to an image or pdf. The conversion is done behind the sce

Spatie 4.1k Jan 1, 2023
A PHP tool that helps you write eBooks in markdown and convert to PDF.

Artwork by Eric L. Barnes and Caneco from Laravel News ❤️ . This PHP tool helps you write eBooks in markdown. Run ibis build and an eBook will be gene

Mohamed Said 1.6k Jan 2, 2023
Sign PDF files with valid x509 certificate

Sign PDF files with valid x509 certificate Require this package in your composer.json and update composer. This will download the package and the depe

Lucas Nepomuceno 175 Jan 2, 2023