The KoolReport Blog

Announcements, discussions, and more for KoolReport and its extended packages.

Awesome KoolReport v3.25.3

We are very glad to let you know that we have released new version 3.25.3 of KoolReport. This version is our continuous effort to ensure the product quality and improvement. The update is completely backward compatible so you feel free to upgrade without worrying about your current works. Upgrade Now.

Enhancements

We have made a number of enhancements to the core. The first one is conversion of code base to comply with PSR Code Standard. This standard is accepted and adopted by wide range of developers all the world because it will help code look cleaner, easier to read and avoid potential code mistakes. Furthermore, by following this standard, our code base could be parsed by intellisense extensions in modern IDEs like Visual Studio Code or PHPStorm.

We have continued to improve the most used widget, Table. In previous version, we have new feature Row Grouping. In this version, we add more flexibility to Table's grouping template and style. We also add new sorting property to let you sort data on the table.

Google has updated the its charting library so we have update our Google Charts in KoolReport as well. If you use old version of KoolReport, it will not be possible to load multiple type of charts (coming from different chart packages). We have spent days to analyze the issues and make it work. If you have this issue, please upgrade to the newest version.

Bug fixes

We have fixed a big issue in Widget when we define data source by function. We also fixed the error related to grouping feature of Table when there is no data. We fixed the data duplication in KoolReport's run() methods. There are some other minor fixes as well that we could not list all here.

New package

The CloudExport is a new added package. The CloudExport will be a service hub to connect to online service provider to export your report to PDF, JPG, PNG or other formats. The package is totally free and available to download. The first cloud service that we implemented is ChromeHeadless.io. CloudExport will be alternative solution for Export package if you find difficulty to install PhantomJs or if you want to off-load the export function to cloud service and save your server's resources for other crucial tasks.

KoolReport Pro

KoolReport Pro 3.25.3 is also released together with new core. This release contains some new package releases: DataGrid 2.5.0, Excel 5.0.0, Inputs 4.5.0, Instant 3.5.0, DrillDown 3.0.0 and Pivot 4.3.0.

As you may aware, KoolReport Pro is yearly subscription based product. To add more flexibility in term of license, we added the Perpetual Usage badge which can be purchased together with KoolReport Pro license. This badge allows you to use KoolReport Pro forever even after subscription is expired. However it does not cover the Priority Support and Free Upgrade privilege.

In addition, we provide the Perpetual Usage, Support and Upgrade badge. If you purchased this badge together with your license, you will own the life-time usage for KoolReport Pro plus you will be entitled Life-Time Priority Support and Life-Time Upgrade privilege.

Summary

The KoolReport 3.25.3 is a must-upgraded version as it contains important enhancements and bug fixes. The update is backward compatible and you can upgrade without any changes to your current reports.

Upgrade Now

Enjoy!!

<3 koolreport team

New Features Of Instant Package 2.0.0

We have just released the Instant 2.0.0 with new features: Report Settings and new Exporter class. The Instant package is Free to download and also be available in the KoolReport Pro 2.32.7.

Report Settings

As you may know that Instant package helps us to use Widget of KoolReport instantly without setting up a whole report. You can use the Widget like Table or Chart in right in your php file. However, due to not setting up report, the resources of Widget may not able to publish to assets or public location which they can be accessed. In this new version, we allow Widget::create function to receive the third parameter which is the settings of temporary report. This feature is extremely important if you are using modern MVC frameworks like Laravel, CodeIgniter.

Widget::create(Table::class,array(
    "dataSource"=>array(
        array("name"=>"Peter","age"=>35),
        array("name"=>"Karl","age"=>32),
    )
),array(
    "assets"=>array(
        "path"=>"../../public/assets",
        "url"=>"/assets"
    )
))

Exporter

New Exporter class allows us to export any HTML or PHP file to PDF or other format.

<?php
require_once "koolreport/autoload.php";
use \koolreport\instant\Exporter;

Exporter::export("/full/path/to/your/file.php")
->pdf(array(
    "format"=>"A4",
    "orientation"=>"portrait"
))
->toBrowser("myfile.pdf");

As you can see, now it is very easy to utilize the power of Export package to export any file to PDF. It does not limit to export the report of KoolReport.

Summary

The new version of Instant package extends the capability of using KoolReport power outside of its environment. This adds flexibility to the usage of KoolReport for general purpose. We are working hard to make KoolReport the best library for reporting as well as extend its usefulness.

<3 koolreport team

Export 2.0.0

We are glad to let you know that we have released Export 2.0.0. In this version, we have solved one of the mysterious issues SSL Handshake.

Exporting HTML to PDF

SSL Handshake

In the previous version, we found that Export functionality works unstably with HTTPS protocols. Most of the cases, it works well. However in some cases, it does not load resources from HTTPS such as images, javascript, css. The SSL Handshake fails that causes interruption in loading those resources. We have solved the problem in this version. If you experience this issue, please upgrade.

Plan for next version

In the next version, we plan to make exporting job work without setting up a full report. In many cases, we just want to export a normal PHP page to PDF. We hope that by adding this new feature, the Export package will be more flexible and extensible in term of use case.

<3 koolreport team

The Easiest Way to Convert HTML To PDF In PHP

This article guides you how to use KoolReport to convert any HTML to PDF even if the HTML is embedded with Javascript and CSS.

Convert HTML to PDF in PHP

About KoolReport

KoolReport is an intuitive and open source PHP Reporting Framework. It is born to make task of building data reports easier and faster. It supports various database connections, powerful data processing and stunning data visualization.

PDF Exporting is one of the cool packages created for KoolReport. The package is built to support KoolReport in exporting reports to PDF. However it can be used for general purpose of converting HTML to PDF. What makes this exporting solution stand out is the ability to support embedded CSS and Javascript beside pure HTML.

Hand-on

Step 1: Create two files MyPage.php and MyPage.view.php

mypage/
├── MyPage.php
├── MyPage.view.php
└── index.php

The MyPage.php contains MyPage class which is derived from KoolReport.

<?php

require "../koolreport/autoload.php";

class MyPage extends \koolreport\KoolReport
{
    use \koolreport\export\Exportable;
}

The MyPage.view.php is put in the same folder with MyPage.php. This view file contains your content in form of HTML, CSS and Javascript that you want to export.

<html>
    <head>
        <title>Content that you want to convert to PDF</title>
    </head>
    <body>
        <!-- CSS Style -->
        <style>
            p {font-size:20px;}
            h1 {color:red}
        </style>

        <!-- Normal HTML content -->
        <h1>Export HTML to PDF</h1>
        <p>It is easy to convert HTML to PDF using KoolReport's Export package</p>
        <p id="extra"></p>

        <!-- Javascript embedded -->
        <script type="text/javascript">
            document.getElementById("extra").innerHTML = "Javascript is working";
        </script>
    <body>
</html>

Step 2: Export To PDF

To generate PDF file and push to browser so that users can download, you do:

<?php
// index.php
require "MyPage.php";
$mypage = new MyPage;
$mypage->export()
->pdf(array(
    "format"=>"A4",
    "orientation"=>"portrait"
))
->toBrowser("mypage.pdf");

Easy, is it? And if you want to save the file instead of pushing to browser, you do:

<?php
// index.php
require "MyPage.php";
$mypage = new MyPage;
$mypage->export()
->pdf(array(
    "format"=>"A4",
    "orientation"=>"portrait"
))
->saveAs("../my_folder/mypage.pdf");

It is all done. Super easy!

Export package

In above example, we demonstrated how to export HTML embedded with CSS and Javascript to PDF. The ability to run Javascript is very important and is the feature that you may not find in other HTML to PDF solutions. This feature allows you to include any kinds of javascript-based charts into your exported PDF. Here is an good example of exporting Javascript Google Charts to PDF.

Pricing

Although KoolReport is a free framework, the Export package is not free. The regular license is only $19. View details.

The Export package is also available in KoolReport Pro, the most advanced version of KoolReport. KoolReport Pro contains all extended packages and Export package is one of them. View details.

<3 koolreport team

How to Export Your Report with Html+Css+Javascript to PDF?

"For a long time, I have looked for but did not find a good solution to export HTML embedded CSS and Javascript to PDF" - John Marshall, one of our customers.

Exporting HTML+CSS+JS to PDF Fig 1: KoolReport converts HTML+CSS+JS to PDF

The problem of John is a common problem of developers working with PDF. We have worked with many PDF libraries such as TCPDF, FPDF, html2pdf or dompdf and we encounter some problems:

  1. It is not intuitive. If you use FPDF or TCPDF, you will feel quite difficult to write content, set style and position element with pure PHP code only. The Html2Pdf and DomPDF provide a better solution which is converting HTML to PDF but they have second problem.
  2. Low level of HTML/CSS support. This problem is associate with Html2Pdf and DomPdf. In those libraries, You should not use the latest HTML or CSS because they will not be rendered all correctly. Always be careful. Sometime the code breaks, things are not displayed in PDF and it takes a lot of time to debug and find a work around in lower level of HTML/CSS.
  3. Javascript is not supported. Uhh! All of them have this issue. Javascript now is the base of many chart libraries. Google Charts, Morris, D3, Sparkline, all of them are using Javascript to generate charts and graphs. So using pure HTML to PDF solution, we must forget all those beautiful charts.

So we was trying to find solution for above problems, a library that we can write PDF file easily with latest HTML/CSS combined with Javascript. And it is now all possible with Export package of KoolReport.

Some simple code to show

This is the view MyReport.view.php

<html>
    <body style="margin: 1in">
        <div class="page-header">My sample report</div>
        <h1>Welcome to KoolReport</h1>
        <div class="page-footer">{pageNum}</div>
    <body>
</html>

This shows how to initiate KoolReport and export to PDF.

<?php
$report = new MyReport;
$report->run();
$report->export()->pdf()->saveAs("MyReport.pdf");

Working example

Let example speaks for itself. Below is a working example of exporting a HTML page with embedded Google Charts.

Example of exporting HTML to PDF

Additional features:

Beside the crucial features above, the Export package supports other necessary settings:

  1. Set page size with predefined size (A3, A4, Letter etc..) or any custom size in px
  2. Set page orientation (portrait or landscape)
  3. Set page margin
  4. Input repeated header text and footer text on each page
  5. Show page number as well as number of pages.

For more information on features and documentation, please visit Export Package.

Summary

Export package is an excellent solution for exporting report to PDF and other formats. Not only can it be used for exporting report, it can help you to export any kind of HTML page to PDF with ease. The price of package is low compared to the benefits it brings to you.

If you have any question regarding this package, do not hesitate to join our forum to get answer. We are happy to assist you.

<3 koolreport team


KoolReport helps to analyze your data and ultimately turn them into visual reports or dynamic dashboards.

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"

Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great product and amazing."

Dr. Lew Choy Onn

"Fantastic framework for reporting!"

Greg Schneider
Get KoolReport Now, It's FREE!