xInvoice

Beautifully designed invoices/ sales order/ purchase orders/ quotes/ bills programmatically with few lines of codes


xInvoice is an advance PHP application to generate beautifully designed invoices/sales-purchase orders/quotes with few lines of codes. You can create attractive, professional invoices using xinvoice. All you need to do is write 2 lines of code to generate invoice in pdf/html format.

By default, You can enter all data of invoice in the config data files and invoice will be generated on the basis of that data. You can modify complete data dynamically using various functions available in script.

This program also allows you to generate invoice from database as it comes with PDOModel database helper class so you can connect with database and fill the invoice values directly from database also.

Not just invoice, order, quote but you can also create any type report easily by copying existing structure and modifying it and pass data from database using PDOModel to generate entirely new report.

You can easily integrate xInvoice script to your application to generate invoices/reports. You need to include the script file in your application. After this, you can create object of class and run render function to generate pdf.

xInvoice comes with more than 100 different designs of invoice/ order / receipt/ quotes. You can also add new templates or customize available templates easily with little knowledge of coding. You can generate the pdf as well as HTML of invoice/reports. In all demo example, we have given button to generate HTML and pdf. Just to mention the obvious, you can also generate pdf/html directly without any button click event also.

  1. Generate beautifully designed invoices, bills, quotes or orders with just 2 lines of code.
  2. Generate invoices, bills, quotes or orders directly from database.
  3. More than 100+ different design option for invoices, bills, quotes and orders.
  4. Create new design option for invoices, bills, quotes and orders easily by copying existing structure and modifying it.
  5. Generate invoices, bills, quotes or orders directly from config data file.
  6. Creates different set of data for different invoices in config by creating different data file.
  7. Each data file allows you to define data, label, css styles and display settings also, making each data file independent of other
  8. You can create completely new report and pass data from database using PDOModel to generate entirely new report.
  9. You can create completely new report by passing data in format of array.
  10. You can generate HTML of invoice also that can be used as template in your other projects
  11. Dynamically calculates item totals.
  12. You can add tax, discount and other totals items dynamically.
  13. You can easily add your own design or theme,logo, color, various styles parameters, items and various kinds of totals.
  14. Dynamic section feature to allow you add data between different sections.
  15. Add watermark and badges.
  16. Add dynamic columns - allows columns to merge or multiply to generate new columns.
  17. Supports REST.
  18. Supports Multi language.
  19. Supports Multi Currency.
  20. Supports callback functionality.
  21. Supports RTL.
  22. Supports various type of formatting (date, time, number, prefix, suffix etc).
  23. Many pages of demo example and documentation

It's really simple! No settings required to generate basic pdf.

Download the folder and extract it. Main files that you are going to use in your application, are in the script folder. Demo and documentation folder can be used for reference purpose. They are not required in your application.

In your application, create a php file and include the following file.

                        require_once “script/xinvoice.php”;
                    

Now you can create object of Xinvoice class and run various function to generate pdf.

                        //Create object of xinvoice application
                           $xinvoice = new Xinvoice();
                        // call render function on object to generate PDF
                        // NOTE: You need to call this function before any html ouput
                        // this will use the data from default data file mentioned in settings file
                           echo $xinvoice->render();
                    

This will generate the basic pdf based on the default data file mentioned in the settings file. The data file contains all the data of pdf. You can create new data file or modify existing file. You can also generate invoice from database.

Please note this is most basic example. xInvoice allows you to do various customization. You can specify various settings in config.php file and data for file can be passed directly or using data-files. The pdf must be outputted before any html output

It's really simple.

 

Here is the HTML Structure of the pdf (simplified):

HTML Structure of xinvoice pdf

This is general structure of pdf, you can change/move/edit/delete/add new sections.

xInvoices offers a various way to customize the PDF documents. There are mainly 2 ways to set data of PDF.
  1. Using Functions -> You can add logo, sender/receiver details, invoice related details, items details, totals, remarks, payment information, terms and condition and many more as per requirement using various functions available in the script. You can also set style related settings, display settings and formatting of complete data. You can retrive the data from database using the pdomodel and set pdf data using these functions.More details about using functions
  2. Data file -> You can pass data as data files. These are simple php files located inside script/config/data-files/ folder and contains the data in form of array. You can modify existing data file or create a new file. More details about using data files

Please note that if you haven't turned off data file settings in config/settings.php page then it will override the data file's data having same key. You can use this functionality to override only specific data. It's liek same key of array will be replaced.

Function Examples

You can either set logo image or pass company name and tagline to be shown at the place of logo. Whether to display logo as image or text can be set in config.php file.

                                // You can set invoice logo using this function or can change directly in config file.
                                $xinvoice->setInvoiceLogo("http://pdocrud.com/assets/img/PDOCrud-logo.png");
                                //OR
                                 //set company array - like company name, logo etc
                                $company = array("logo" => "http://pdocrud.com/assets/img/PDOCrud-logo.png");
                                //set company data       
                                $xinvoice->setInvoiceCompanyData($company);   
                            

Dates

You can set date and due dates of invoice. You can also set in config to auto set date to current date.

                                // You can set invoice date using this function or can change directly in config file.
                                $xinvoice->setInvoiceDate("01/04/2018");

                                // You can set invoice due date using this function or can change directly in config file.
                                $xinvoice->setInvoiceDuedate("01/05/2018");
                            

Header

Header normally contains information like invoice no, date, due date, total due etc. This can be set using this function.

                                //set header array
                                $header = array("no" => "Nx-1001", "date" => "01/04/2018");
                                //set header data 
                                $xinvoice->setInvoiceHeaderData($header);  
                            

Sender (From)

Set sender data like name, address, city, phone. You can add as many details as you want.

                                //set from array
                                $from = array("name" => "Test Company", "address1"=>" Dummy address");
                                //set from data 
                                $xinvoice->setInvoiceFromData($from);   
                            

Receiver (To)

Set receiver data like name, address, city, phone. You can add as many details as you want.

                                //set to array
                                $to = array("name" => "Test Company", "address1"=>" Dummy address");
                                //set to data 
                                $xinvoice->setInvoiceToData($to); 
                            

Items

You can set items one by one using setInvoiceitem() function or if you want to add all items togther, you can use setInvoiceItems() with items array. Items can contain any number of columns that can fit in page. The total amount of item must have "total" key to calculate items totals.

                                 //Create item with key and value to be used for item information section
                                $item = array("name" => "Graphic Card", "desc" => "Graphic Card of computer", "qty" => 2, "rate" => 100, "total" => 200);
                                // You can set invoice item using this function or can change directly in config file.
                                $xinvoice->setInvoiceitem($item);
                               //Create items array with key and value to be used for item information section
                                $items[] = array("name" => "Motherboard", "desc" => "motherboard of computer", "qty" => 1, "rate" => 100, "total" => 100);
                                $items[] = array("name" => "Ram", "desc" => "ram of computer", "qty" => 2, "rate" => 100, "total" => 200);
                                // You can set invoice items using this function or can change directly in config file.
                                $xinvoice->setInvoiceItems($items);
                            

Payment

You can set payment related information like bank details, payment methods , notes etc.

                                //set payment array
                                $payment = array("method" => "Cash on delivery", "note"=>"Please make sure to have req. cash on delivery day");
                                //set payment data 
                                $xinvoice->setInvoicePaymentData($payment); 
                            

Message

You can set message before footer to be displayed using setInvoiceMessageData() function for example thank you message, remark or signature column.

                                //set message array
                                $message = array("thankyou" => "Thank you for your business", "note"=>"Lorem Ipsum is simply dummy text of the printing and typesetting industry");
                                //set message data 
                                $xinvoice->setInvoiceMessageData($message); 
                            

You can set terms and conditions or any other information to be displayed in footer using setInvoiceFooterData() function/

                                //set footer array
                                $footer = array("note" => "Lorem Ipsum is simply dummy text of the printing and typesetting industry.");
                                //set footer data 
                                $xinvoice->setInvoiceFooterData($footer);
                            

Please note that if you haven't turn off data file in settings page then it will override the label with same key. You can use this functionality to override only specific data.

Set company related labels, it's not required if you are using logo as image, below example is just show to explain it's working.

                                //set company array
                                $company = array("logo" => "http://pdocrud.com/assets/img/PDOCrud-logo.png");
                                //set company label       
                                $xinvoice->setInvoiceCompanyLabel($company);      
                            

Dates

You can set label for date and due dates of invoice.

                                // You can set invoice date label using this function or can change directly in config file.
                                $xinvoice->setInvoiceDateLabel("Invoice Date: ");

                                // You can set invoice date using this function or can change directly in config file.
                                $xinvoice->setInvoiceDueDateLabel("Invoice DueDate: ");
                            

Header Label

Header label normally contains information like invoice no, date, due date, total due etc. This can be set using this function.

                                //set header array
                                $header = array("no" => "Inv. No: ");
                                //set header label 
                                $xinvoice->setInvoiceHeaderLabel($header);
                                // or You can set invoice number using this function or can change directly in config file.
                                $xinvoice->setInvoiceNoLabel("Inv. No.: ");      
                            

Sender Label (From)

Set sender label like name, address, city, phone. You can add as many details as you want.

                                //set from array
                                $from = array("name" => "Sender: ");
                                //set from label 
                                $xinvoice->setInvoiceFromLabel($from);   
                            

Receiver Label (To)

Set receiver label like name, address, city, phone. You can add as many details as you want.

                                //set to array
                                $to = array("name" => "Receiver: ");
                                //set to label 
                                $xinvoice->setInvoiceToLabel($to);  ; 
                            

Payment Label

You can set payment related information like bank details, payment methods , notes etc.

                                //set payment array
                                $payment = array("method" => "Payment method: ", "note"=>"Important Note: ");
                                //set payment label 
                                $xinvoice->setInvoicePaymentLabel($payment); 
                            

You can set terms and conditions or any other information label to be displayed in footer using setInvoiceFooterData() function/

                                 //set footer array
                                $footer = array("note" => "Terms and Conditions: ");
                                //set footer label 
                                $xinvoice->setInvoiceFooterLabel($footer);
                            

You can apply style different sections of invoice by setting style of that the section. You can set this style information directly in data file or using the function setInvoiceStyleSettings().

                                /**
                                * Set style settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   bool     $style               set style of section true to show, false to style  
                                * return   object                          Object of xinvoice
                                */
                                // style complete header"
                               $xinvoice->setInvoiceStyleSettings("header","","background: #ccc");
                               //
                               $xinvoice->setInvoiceStyleSettings("invoice","date","font-weight:bold");     
                            

You can hide/display different sections of invoice by setting display of that the section. You can set this display information directly in data file or using the function setInvoiceDisplaySettings(). If true or not set display of that section, it will show the section. To hide any section, you need to set display false of that section. You can hide complete section or subsection of that section.

                                /**
                                * Set display settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   bool     $display               set display of section true to show, false to hide  
                                * return   object                          Object of xinvoice
                                */
                                // hide complete header
                               $xinvoice->setInvoiceDisplaySettings("header","",false);
                               //hide from(Sender) "name" not complete "from"(sender)
                               $xinvoice->setInvoiceDisplaySettings("from","name",false);   
                            

You can format different sections of invoice by setting format of that the section. You can set this format information directly in data file or using the function setInvoiceFormatSettings(). For example if you want to format date as "d-m-y", or add prefix/suffix to quantity column, you can do this using this function.

                                /**
                                * Set format settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   bool     $format               set format of section true to show, false to hide  
                                * return   object                          Object of xinvoice
                                */
                                // hide complete header
                               $xinvoice->setInvoiceFormatSettings("header","",false);
                               //hide from(Sender) "name" not complete "from"(sender)
                               $xinvoice->setInvoiceFormatSettings("from","name",false);
                               echo $xinvoice->render(); 
                            

xInvoice also provides REST support to generate PDF. You can pass invoice data as post data and it generates pdf. Generated pdf saved in downloads folder and it returns the path of the invoice generated.

For example, if you are developing a mobile application and want to generate pdf invoice, you can use pass your data to application as post and it will generate the pdf and will return the path of generated pdf.

Please note that it provides basic rest support, it doesn't have the authentication and other features like our script RESTp

Many times, you want to generate the dynamic columns to format your data for example, you might want to generate totals from qty and rate multiplication or suppose you want to merge item name and description column in a single column, you can use this addCol function to generate the dynamic columns. Dynamic columns are always added in the last of the item column position, you can change position of column using reorder items function. You can use "merge", "sum", "multiply", "divide" and "subtract" between 2 columns to generate new column.

xInvoice contains 100s of predefined templates that you can directly use in your project. You can also create new template easily by copying existing content. Templates are basically php, html and css code. You will need basic knowledge of php, html and css to create/modify the template. Template structure is specified in HTML structure section. It's quite easy to change if know basics of php and css. You can add new sections, move one sub section to different subsection.

Create New Template

Go to script/templates folder. Templates folder contains 4 folder, You can chose any one of folder to create new template or you can create a new folder. You need to create a file. If you want to use any existing template structure, you can copy and do required changes. You can set template name in settings (Config.php) or at the time of object creation.

Edit Existing Template

Go to script/templates folder. Chose the template you want to modify. Now create a new file and copy the content of that file from existing template and do the required customization. Now, You can set template name in settings (Config.php) or at the time of object creation.

CSS for templates can be added in 2 ways. One way to add it using the data files style key and other way is write css in the template files.

If you want to edit any template, best way is to do so, is to create a new template and copy some existing similar template to prevent overwriting in case of future updates.

We don't provide support for custom templates developed by user. All invoices are in table format to make sure that it prints the pdf in proper format. We have given option to generate the HTML also but it won't be responsive.

xInvoice provides a unique way to specify data to pdf by creating the data files. Data files contains data, label, style, display and formatting information of invoice pdf. You can create as many data files as you want. For each xinvoice object, you can pass data file name as parameter. You can specify default data file name in the settings page. Data files can be used to support multi-language easily. You can create data files for each language and pass as data file name for each different language in xInvoice object.

Data files contains basically 5 parts.

  1. Data settings - All content fields to be displayed in pdf - e.g
                                        $xData["invoice"]["no"]["data"] = "DY-13123";
                                        $xData["invoice"]["date"]["data"] = "01-08-2018";
                                    
  2. Label settings - All label fields to be displayed in pdf - e.g
                                        $xData["invoice"]["date"]["label"] = "DATE: ";
                                        $xData["invoice"]["total_due"]["label"] = "TOTAL AMOUNT: ";
                                    
  3. Style settings - All styles related settings to be used for pdf - e.g
                                        $xData["to"]["name"]["style"] = "font-size: 16px";
                                        $xData["company"]["logo"]["style"] = "max-width:300px";
                                    
  4. Display settings - Whether to show or hide particular section in pdf - e.g
                                        $xData["itemcount"]["display"] = false;
                                        $xData["message"]["display"] = true;
                                    
  5. Formatting settings - Formmating related settings of various content of pdf - e.g
                                        $xData["invoice"]["due_date"]["format"] = array("date", "Y-m-d");
                                        $xData["invoice"]["total_due"]["format"] = array("currency", "$");
                                    

You can specify new data, label, style, display and formatting settings and use it in your template. We have already created many data files with different style, data and formatting settings that you can directly use or customized it to fit to your need. If you are adding a new key, then you should add that in your template to make is show.

In most of the cases, you will need a fixed layout based template with fixed label, style and formatting So you can create a single default data file where label, style, display and formatting can be specified and Only data needs to be specified dynamically by using various set data function.

For more customization I included custom classes

Complete settings file fields and explanation of various fields

                        /* Configuration Settings */
                        /* *********************** database conection settings  *********************** */
                        /* *********************** required only if you want to get data for pdf from the database using PDOModel object  *************** */
                        //Set the host name to connect for database
                        $xSettings["hostname"] = "localhost";
                        //Set the database name
                        $xSettings["database"] = "xinvoice";
                        //Set the username for database access
                        $xSettings["username"] = "root";
                        //Set the pwd for the database user
                        $xSettings["password"] = "";
                        //Set the database type to be used
                        $xSettings["dbtype"] = "mysql";
                        //Set the database type to be used
                        $xSettings["characterset"] = "utf8";
                        //Set the default language to be used. This is for the success and error message language.
                        $xSettings["lang"] = "en";

                        /* ******************** data settings ***************************************** */
                        //whether to load the default data or not.
                        $xSettings["defaultData"] = true;
                        //Set the name of default data file(without extension) to be used.
                        $xSettings["datafile"] = "data";
                        //whether to use logo image (image) or company name and tagline(text)
                        $xSettings["companylogo"] = "image";
                        //whether to auto calculate item wise total or not
                        $xSettings["autoCalcItemTotal"] = true;
                        //Default Number format (decimal point, separator, thousand separator)
                        $xSettings["numberformat"] = array(2, 1);
                        //Get default value of date. Acceptable values are default data date(config_date) or current date(current_date).
                        // if current_date entered, then it will show the current date else it will show the date from data.
                        $xSettings["defaultDateVal"] = "config_date";
                        //Get default value of total due from grand total(auto) or from config data(config) 
                        $xSettings["defaultTotalDueVal"] = "auto";
                        //Set default background color of the invoice
                        $xSettings["backgroundColor"] = "#e2e2e2";
                        //Set default font color of the invoice
                        $xSettings["fontColor"] = "#e1a827";
                        //Default currency symbol
                        $xSettings["currency"] = "$";
                        //Default currency direction
                        $xSettings["currencyDirection"] = "left";
                        //whether to add watermark or not
                        $xSettings["watermark"] = false;
                        //If watermark is yes, then whether watermark text or image
                        $xSettings["watermarkType"] = "text";
                        //Water mark value
                        $xSettings["watermarkValue"] = "Invoice";
                        //Default pdf file name 
                        $xSettings["filename"] = "invoice.pdf";
                        //whether to ouput it on browser or browser+force download or save file at particular location
                        $xSettings["output"] = "I";
                        //whether to email the pdf generated or not
                        $xSettings["emailpdf"] = false;
                        //delimiter for csv file
                        $xSettings["delimiter"] = ",";
                        //whether to enable the logs.
                        $xSettings["enableLogs"] = true;
                        //Path of log file
                        $xSettings["logFile"] = XInvoiceABSPATH."logs/logs.txt";
                        /********************** mpdf object parameters *********/
                        //mode 
                        $xSettings["mode"] = "";
                        //paper size
                        $xSettings["format"] = "A4";
                        //font size
                        $xSettings["default_font_size"] = 0;
                        //default font
                        $xSettings["default_font"] = "";
                        //mg left
                        $xSettings["mgl"] = 5;
                        //mg right
                        $xSettings["mgr"] = 5;
                        //mg top
                        $xSettings["mgt"] = 5;
                        //mg bottom
                        $xSettings["mgb"] = 16;
                        //mg header
                        $xSettings["mgh"] = 5;
                        //mg footer
                        $xSettings["mgf"] = 9;
                        //page orientation
                        $xSettings["orientation"] = "P";
                        //document direction
                        $xSettings["direction"] = "ltr";
                        //Set this true if you do not need complex table borders, 
                        //improves processing time of mpdf
                        $xSettings["simpleTable"] = true;
                        /****************** PDF Meta Data *****/
                        //PDF title
                        $xSettings["title"] = "";
                        //PDF author
                        $xSettings["author"] = "";
                        //PDF creator
                        $xSettings["creator"] = "";
                        //PDF subject
                        $xSettings["subject"] = "";
                        //PDF keywords
                        $xSettings["keywords"] = "";

                        /* * ************** Email Related Settings (if 'emailpdf' setting is set true)***************** */
                        //whether to use phpemail or smtp. For windows hosting, you need SMTP
                        $xSettings["emailMode"] = "PHPMAIL";

                        $xSettings["SMTPHost"] = "ajax";

                        $xSettings["SMTPPort"] = 25;

                        $xSettings["SMTPAuth"] = true;

                        $xSettings["SMTPusername"] = "";

                        $xSettings["SMTPpassword"] = "";

                        $xSettings["SMTPSecure"] = "";

                        $xSettings["SMTPKeepAlive"] = true;
                    

xInvoice supports various callback functions at various events that can be used to perform specific operations as required. Callback functions are very useful to perform special operation as per requirement. For example, if you want to change the change the data before html formatting, you can use callback functions. You need to add call back function and needs to include function definition in the script/xinvoice.php file..

                            $xinvoice =  new Xinvoice();
 
                            $xinvoice->addCallback("before_html_formatting", "beforeHtmlFormatting");

                            $xinvoice->addCallback("after_html_formatting", "afterHtmlFormatting");

                            $xinvoice->addCallback("after_pdf", "afterPDF");

                            $xinvoice->addCallback("after_html", "afterHTML");

                            echo $xinvoice->render();
                        

Get Settings

Gets specific setting from settings defined in config.php

                                /**
                                * Get particular configuration setting
                                * @param    string   $setting              Config Key for which setting needs to be retreived 
                                * return    mixed                          Configuaration setting value
                                */
                                function getSettings($setting)
                        

Set Settings

Set specific setting in settings defined in config.php

                                /**
                                * Set particular configuration setting
                                * @param   string   $setting                   Config key for setting
                                * @param   mixed    $value                     Value for setting
                                * return   object                              Object of class
                                */
                                function setSettings($setting, $value)
                        

Set current language

Set current language for the success and error messages

                                /**
                                * Set current language
                                * @param   string   $lang                            language to be used
                                * return   object                                    Object of class
                                */
                                function setCurrentLang($lang) 
                        

Get current language data

Get current language data for the success and error messages

                                /**
                                * Return language data
                                * @param   string   $param                           Get data for language
                                * return   sting                                     language translation for the parameter
                                */
                                function getLangData($param) 
                        

Set current language data

Set current language data for the success and error messages

                               /**
                                * Set language data
                                * @param   string   $param                          lanuguage key for which data needs to save
                                * @param   string   $val                            Value for the language parameter
                                * return   object                                   Object of class
                                */
                                function setLangData($param, $val) 
                        

Set template name

Set template name for the pdf to be generated.

                               /**
                                * Set template name
                                * @param   string   $templatename                   template name to be used
                                * return   object                                   Object of class
                                */
                                 function setTemplateName($templatename) 
                        

Get template name

Get template name for the pdf to be generated.

                                /**
                                * get current template name
                                * return   string                                   current template name
                                */
                                 function getTemplateName() {
                        

RTL Support

Set the document RTL state

                                /**
                                * Set the document RTL state
                                * @param   string   $direction                      Defines the directionality of the document.Default is ltr
                                * return   string                                   current template name
                                */
                                function setDirectionality ($direction = "ltr") 
                        

Callback

Add callback function

                               /**
                                * Add callback function to be called on certain event
                                * @param   string   $eventName                       Eventname for which callback function needs to be called
                                * @param   string   $callback                        Name of callback function
                                * return   object                                    Object of class
                                */
                                function addCallback($eventName, $callback) 
                        

Reset Total Fields

Reset all total fields

                                /**
                                * Reset all totals fields
                                * return   object                                    Object of class
                                */
                                function resetTotal() 
                        

Reset items Fields

Reset all item columns

                                /**
                                * Reset all items
                                * return   object                                    Object of class
                                */
                               function resetItemFields()
                        

Set pdf data array

Set complete data array to be used for generating invoice

                                /**
                                * Set complete data array to be used for generating invoice
                                * @param   array   $data                  data to be set
                                * return   object                         Object of class
                                */
                               function setInvoiceDataArray($data) 
                        

Set pdf section wise data

Generic function to set various data parts of invoice

                                /**
                                * Generic function to set various data parts of invoice
                                * @param   array   $data                  data to be set
                                * @param   array   $type                  type of data
                                * return   object                         Object of class
                                */
                               function setInvoiceData($data, $type)  
                        

Set header section data

Set invoice 'header' details e.g. invoice no, date, due date, total due

                                /**
                                * Set invoice 'header' details e.g. invoice no, date, due date, total due
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceHeaderData($data) 
                        

Set from (Sender) section data

Set invoice 'from'(sender) details e.g. name, address, city, postalcode etc

                                /**
                                * Set invoice 'from' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceFromData($data)
                        

Set to (receiver) section data

Set invoice 'to'(receiver) details e.g. name, address, city, postalcode etc

                                /**
                                * Set invoice 'to' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceToData($data) 
                        

Set company section data

Set invoice company details e.g. logo, name etc

                                /**
                                * Set invoice 'Company' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceCompanyData($data)
                        

Set Payment section data

Set invoice Payment details e.g. method, note etc

                                /**
                                * Set invoice 'Payment' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoicePaymentData($data)
                        

Set Total section data

Set invoice Total details e.g. subtotal, discount, tax etc

                                /**
                                * Set invoice 'Total' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceTotalData($data)
                        

Set Message section data

Set invoice Message details e.g. notes, remarks, thank you message etc

                                /**
                                * Set invoice 'Message' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                 function setInvoiceMessageData($data)
                        

Set Footer section data

Set invoice Footer details e.g. terms and condition, notes, remarks etc

                                /**
                                * Set invoice 'Footer' details 
                                * @param   array   $data                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                                function setInvoiceFooterData($data)
                        

Set Logo section data

Set invoice Logo details

                                /**
                                * Set invoice 'Logo'  
                                * @param   string   $logo                  logo of company
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceLogo($logo) 
                        

Set Number section data

Set invoice Number details

                                /**
                                * Set invoice 'Number'  
                                * @param   string   $no                    invoice no. to be set
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceNo($no)
                        

Set Date section data

Set invoice Date details

                                /**
                                * Set invoice 'Date'  
                                * @param   string   $date                  invoice date to be set
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceDate($date)
                        

Set 'Due Date' section data

Set invoice 'Due Date' details

                                /**
                                * Set invoice 'Due Date'  
                                * @param   string   $date                  invoice due date to be set
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceDueDate($date) 
                        

Set Items section data

Set invoice Items details

                                /**
                                * Set invoice Items  
                                * @param   array   $items                  array of items to be added 
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceItems($items)
                        

Set single item section data

Set invoice single item details

                                /**
                                * Set invoice single item
                                * @param   array   $item                   Item to be added 
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceItem($item) 
                        

Set invoice different section data

Set invoice in between section details

                                /**
                                * Set invoice different section data
                                * @param   string   $sectionName           section name to be set
                                * @param   string   $val                   value of section
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceSections($sectionName, $val) 
                        

Set invoice complete data

Set complete data of invoice

                                /**
                                 * Set invoice complete data passed as in array format
                                 * @param   array   $invoiceData            Complete invoice data array
                                 * return   object                          Object of xinvoice
                                 */
                                public function setInvoiceCompleteData($invoiceData) {
                        

Set Invoice labels

Generic function to set label

                                 /**
                                * Generic function to set label
                                * @param   array   $label                  label to be set
                                * @param   array   $type                  type of label
                                */
                               function setInvoiceLabel($label, $type)
                        

Set Invoice header labels

Set invoice 'header' details label

                                /**
                                * Set invoice 'header' details 
                                * @param   array   $label                   label in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceHeaderLabel($label)
                        

Set Invoice from labels

Set invoice 'from' details label

                                /**
                                * Set invoice 'from' details 
                                * @param   array   $label                   label in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceFromLabel($label)
                        

Set Invoice to labels

Set invoice 'to' details label

                                /**
                                * Set invoice 'to' details 
                                * @param   array   $label                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceToLabel($label)
                        

Set Invoice Company labels

Set invoice 'Company' details label

                                /**
                                * Set invoice 'Company' details 
                                * @param   array   $label                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceCompanyLabel($label)
                        

Set Invoice Payment labels

Set invoice 'Payment' details label

                                /**
                                * Set invoice 'Payment' details 
                                * @param   array   $label                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoicePaymentLabel($label)
                        

Set Invoice Message labels

Set invoice 'Message' details label

                                /**
                                * Set invoice 'Message' details 
                                * @param   array   $label                   data in format of array
                                * return   object                           Object of xinvoice
                                */
                               function setInvoiceMessageLabel($label)
                        

Set Invoice Footer labels

Set invoice 'Footer' details label

                                /**
                                * Set invoice 'Footer' details 
                                * @param   array   $label                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceFooterLabel($label)
                        

Set Invoice Total labels

Set invoice 'Total' details label

                                /**
                                * Set invoice 'Total' details 
                                * @param   array   $label                   data in format of array
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceTotalLabel($label)
                        

Set Invoice Invoice no labels

Set invoice 'Invoice no' details label

                                /**
                                * Set invoice 'Invoice no'  
                                * @param   string   $label                 invoice no label to be set
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceNoLabel($label)
                        

Set Invoice Invoice Date labels

Set invoice 'Invoice Date' details label

                                /**
                                * Set invoice 'Date' Label  
                                * @param   string   $label                 invoice date label to be set
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceDateLabel($label) 
                        

Set Invoice Due Date labels

Set invoice 'Due Date' details label

                                /**
                                * Set invoice 'Due Date'  
                                * @param   string   $label                 invoice due date label to be set
                                * return   object                          Object of xinvoice
                                */
                        

Set Invoice Invoice Items labels

Set invoice 'Invoice Items' details label

                                /**
                                * Set invoice Items label  
                                * @param   array   $label                  array of items label to be added 
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceItemsLabel($label)
                        

Display settings of invoice

Set display settings of invoice sections

                                /**
                                * Set display settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   bool     $display               set display of section true to show, false to hide  
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceDisplaySettings($section, $subsection = "", $display = true)
                        

Style settings of invoice

Set style settings of invoice sections

                                /**
                                * Set style settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   string   $style                 set style of section
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceStyleSettings($section, $subsection = "", $style = "")
                        

Format settings of invoice

Set format settings of invoice sections

                               /**
                                * Set format settings of invoice sections  
                                * @param   string   $section               section of invoice
                                * @param   string   $subsection            sub section of invoice (optional)
                                * @param   array    $format                set format of the invoice section
                                * return   object                          Object of xinvoice
                                */
                               function setInvoiceFormatSettings($section, $subsection = "", $format = "")
                        

Get mpdf object

Get mpdf object to apply various functions directly if want.

                               /**
                                * Get mpdf object
                                * @param   array   $param                      Paramater for mpdf object
                                * return   object                              Object of mpdf
                                */
                               function getMPDFObj($param = array())
                        

Apply watermark to mpdf

Settings related to watermark can be done in config.php page

                               /**
                                * Apply watermark to mpdf
                                * return   object                              Object of mpdf
                                */
                               function setWatermark($mpdf)
                        

Add dynamic totals field

Add totals fields and define their dynamic calculation

                               /**
                                * Add dynamic totals field
                                * @param   string   $totalId                   unique id for each totals
                                * @param   string   $lableName                 Lable for the field
                                * @param   array    $data                      data to be used to generate the field
                                * @param   string   $operation                 Whether to use sum or percentage operation to generate field
                                * @param   string   $param                     Parameter like how much percentage etc.
                                * @param   bool     $negative                  Whether field will be negative or positive for further dynamic_columns.
                                * return   object                              Object of xinvoice
                                */
                               function addInvoiceTotal($totalId, $lableName = "", $data = array(), $operation = "+", $param = 0, $negative = false) {
                        

Add dynamic column to item

Directly generate new column using 2 columns of items


                            /**
                           * Add a new column to the invoice table
                           * @param   string   $colName                            Unique Column name to be added
                           * @param   string   $labelName                          Label name (heading) of column
                           * @param   string   $type                               Calculation type of the column whether it is generate using 'sum', 'merge' etc function
                           * @param   array    $parameters                         Columns (or value) on the basis of which new column to be added
                           * return   object                                       Object of class
                           */
                            function addCol($colName, $labelName, $type, $parameters = array()) 
                        

Converts a csv file to pdf

Directly convert csv file to pdf

                               /**
                                * Converts a csv file to pdf
                                * @param   string   $filename                           csv filename 
                                * @param   string   $param                              Set parameter (style, class etc) for the pdf table generated
                                * return   object                                       Object of class
                                */
                               function csvToPDF($filename, $param = array()) 
                        

Converts a xml file to pdf

Directly convert xml file to pdf

                              /**
                                * Converts a xml file to pdf
                                * @param   string   $filename                           xml filename 
                                * @param   string   $param                              Set parameter (style, class etc) for the pdf table generated
                                * return   object                                       Object of class
                                */
                               function xmlToPDF($filename, $param = array()) {
                        

Converts a html file to pdf

Directly convert html file to pdf

                               /**
                                * Converts a html file to pdf
                                * @param   string   $html                               html data 
                                * return   object                                       Object of class
                                */
                               function htmlToPDF($html)
                        

Get PDO Model Obect

PDOModel object to perform database related queries

                               /**
                                * Get PDOModel object
                                * return   object                              Object of PDOModel class
                                */

                               function getPDOModelObj() 
                        

Render function

render data passed as PDF or HTML

                                /**
                                * render data as PDF or HTML
                                * @param   string  $operationType              whether to generate PDF or HTML
                                * @param   array   $data                       Optional parameter to be passed
                                * return   mixed                               PDF or HTML
                                */    
                               function render($operationType = "PDF", $data = array())
                        

Prerequisites

In order to check whether it will work for you or not, you can test the generation of pdf using mpdf library. The mpdf library can be downloaded from their website. https://mpdf.github.io/

Faq's?

In order to check whether it will work for you or not, you can test the generation of pdf using mpdf library. The mpdf library can be downloaded from their website. https://mpdf.github.io/

Limitations

In order to check whether it will work for you or not, you can test the generation of pdf using mpdf library. The mpdf library can be downloaded from their website.

Version 1.1 (10/31/2018)

                        Initial Release
                    

 

Thanks so much to