Export

Overview #

One of the most important features in a reporting tools or framework is the ability to export report to other formats such as PDF. The exported file can be pushed to download from browser, attached to email or simply stored for later used.

For longtime, exporting HTML To PDF is quite difficult due to several reason. First, PDF is still behind browser in term of CSS supporting which makes modern version of CSS does not work in PDF like it does in browser. The same happens to HTML. Second, modern chart and graphs uses Javascript to render. Google Charts suite is a big example. That hinders the ability to include those beautiful charts into PDF.

This Export package solved those problems and more.

Features #

  1. Exporting your HTML report to PDF and common image formats (JPG, PNG, BMP ..)
  2. Fine-pixel printing report with different sizes: A3, A4, A5, Letter, Legal, Tabloid
  3. PDF paging supported with customized repeated header and footer text in each page. The page number and total number of page are supported as well.
  4. In-page Javascript supported. This means you can include any kind of modern charts such as Morris, D3, Sparkline. You name it, we support it!
  5. Exported file can be save to local drive or can be pushed to browser for user to download.

What can I do with this package? #

  1. Well, you can export your report and store for later usage.
  2. You can export to PDF and attach it to email and send to key persons every week.
  3. You can let user download your report in PDF or their preferred image file.
  4. You can create invoice in familiar HTML, export it to PDF then send to your customer. That's professional!
  5. There will be much more! We will update this list.

Installation #

By downloading .zip file #

  1. Download zip file from My Licenses
  2. Unzip
  3. Copy the folder export into koolreport folder, it will look like below
  4. Download correct version of phantomjs for your OS into koolreport/export/bin folder
koolreport
├── core
├── export

By composer #

If you have purchased the package then you can follow these steps to install

  1. Login to koolreport.com
  2. Go to My Licenses
  3. Click Get Token For Composer button
  4. Copy the text and save to file auth.json next to composer.json
  5. Add the repositories to composer.json like below
  6. Run composer update to install package
  7. Download correct version of phantomjs for your OS into koolreport/export/bin folder

composer.json

{
    "repositories":[
      {"type":"composer","url":"https://repo.koolreport.com"}
    ],
    "require":{
        "koolreport/export":"*",
        ...
    }
}

Your auth.json will look like this:

{
    "http-basic": {
        "repo.koolreport.com": {
            "username": "your@email.com",
            "password": "your-secret-token"
        }
    }
}

Note: Please add your auth.json to .gitignore as it contains your secret login information.

Download phantomjs #

  1. Download PhantomJS execution file for operating system you are using:
  2. Unzip and put the execution file into the koolreport/export/bin folder

Installation Node.js and Chromium #

In case you want to use chrome headless to export to PDF, please follow these steps:

  1. Download the export package and unzip it.
  2. Copy the folder export into folder koolreport/packages
  3. If you have admin right, download node.js from this link for your operating system https://nodejs.org/en/download/. Then install it on your server and go to folder koolreport/packages/export and run the following command line: npm i puppeteer
  4. If you can't install node.js on your server, please download the following portable node.js for your operating system:

All done! Enjoy exporting your report with KoolReport now.