So now we will attempt to disclose how to make pdf page in CodeIgniters(CodeIgniter TCPDF Integration).To make pdf page, we utilize library for making pdf, in this case I will utilize library tcpdf from Other than utilizing tcpdf, you can likewise utilize another library, for example, fpdf,dompdf, and so on.I would like to have feedback on my infinityknow.com blog.Your valuable feedback, question, or comments about this article are always welcome.
Codeigniter View File Pdf Page InWe will integrate dompdf library from scratch so no issue if you dont know about dompdf library. We generally require to generate PDF for invoice, data, information, subscription etc. If you use any PHP framework like laravel, code php, yii etc then you have option to other package for generate HTML file into PDF. But if you are working on Codeigniter then you fetch problem to how to do it. But in this article i am going to give you very simple example to html to pdf convert using DomPDF library. DomPDF library through we can simply render html layout into PDF file. DomPDF library also allow to write external style sheets, inline style tags, font size, font color etc. Dompdf library is available on composer package so if you are working with composer then also you can use it. So, i am going to share with you example of how to generate PDF file from HTML layout using DomPDF library, If you dont know how to implement it then no worry because i am doing from scratch and you have to just follow few step to create PDF file. Codeigniter View File Download Fresh VersionStep 1: Download Fresh Codeigniter 3 In First step we will download fresh version of Codeigniter 3, so if you havent download yet then download from here: Download Codeigniter 3. After Download successfully, extract clean new Codeigniter 3 application. Step 2: Installation Setup In first step we have to download one library and one dependency of dompdf so follow bellow things. Pdf.php: we have to download Pdf.php file from GitHub, So first lets download from here: Click Here to download Pdf.php file. After download successfully we have to copy to applicationlibrariesPdf.php file. Dompdf: we have to download dompdf library from GitHub, So first lets download from here: Click Here to download dompdf. After download extract it to your applicationlibraries folder and rename it to dompdf. Ok, now Download php-font-lib from GitHub, So first lets download from here: Click Here to download php-font-lib classes. ![]() Read Also: Laravel 5 export to pdf using maatwebsite example Step 3: Add Route In this step, we will add one route mypdf for demo, that way when we run this route we will download pdf file, So lets add following route on your routes.php file. BASEPATH) OR exit(No direct script access allowed); routedefaultcontroller welcome; route404override; routetranslateuridashes FALSE; routemypdf welcomemypdf; Step 4: Add Controller Method In this step we require to add mypdf method on welcome controller, So lets add with following code. So now as bellow i created mypdf.php with some html code, so you have to copy bellow code and create on view folder: applicationviewsmypdf.php Codeigniter 3 - Generate PDF from view using dompdf library with example Codeigniter 3 - Generate PDF from view using dompdf library with example Id Name Email 1 Hardik email protected 2 Paresh email protected Ok, now we are ready to run our PDF generator example. So lets run bellow command on your root directory for quick run: php -S localhost:8000 Now you can open bellow URL on your browser: Read Also: Codeigniter 3 - CRUD(Create, Read, Update and Delete) using JQuery Ajax, Bootstrap, Models and MySQL I hope it can help you. Im a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |