PHPackages                             koolreport/cloudexport - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. koolreport/cloudexport

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

koolreport/cloudexport
======================

Export to pdf, image using chromeheadless.io's cloud export service

4.2.1(1y ago)7197.7k↓37.4%1[1 issues](https://github.com/koolreport/cloudexport/issues)MITPHP

Since Jul 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/koolreport/cloudexport)[ Packagist](https://packagist.org/packages/koolreport/cloudexport)[ Docs](https://www.koolreport.com)[ RSS](/packages/koolreport-cloudexport/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (1)Versions (29)Used By (0)

Introduction
============

[](#introduction)

`CloudExport` helps to export your report to PDF or other format using export service providers. [ChromeHeadless.io](https://chromeheadless.io) is the first cloud service we implemented for CloudExport. ChromeHeadless.io is developed by us so you can assure the compatibility as well as the quality of result.

Installation
============

[](#installation)

By downloading .zip file
------------------------

[](#by-downloading-zip-file)

1. [Download](https://www.koolreport.com/packages/cloudexport)
2. Unzip the zip file
3. Copy the folder `cloudexport` into `koolreport` folder so that look like below

```
koolreport
├── core
├── cloudexport
```

By composer
-----------

[](#by-composer)

```
composer require koolreport/cloudexport

```

ChromeHeadless.io
=================

[](#chromeheadlessio)

Overview
--------

[](#overview)

**ChomeHeadless.io** is an online service helps to convert HTML to PDF and other image format. Running on highly optimized hardware and software, the ChomeHeadless.io will save your time in installing headless browsers like Phantomjs or Google Chrome. It also saves you server resources which you may reserve for other crucial tasks. The Chromeheadless.io is in beta version so all are free.

Get Token Key
-------------

[](#get-token-key)

1. Register an account in [ChromeHeadless.io](https://chromeheadless.io). An email with title *"Welcome to ChromeHeadless.io"* will be sent to you in few minutes after your sign up.
2. Use account credential in welcome email to log in our system.
3. Go to [tokens management](https://chromeheadless.io/account/tokens) page
4. Hit `Generate` button to generate token key.

Example
-------

[](#example)

**MyReport.php**

```
class MyReport extends \koolreport\KoolReport
{
    //Register cloud export service in your report
    use \koolreport\cloudexport\Exportable;
}

```

**MyReportPDF.view.php**

```

        This is my first export using Chromeheadless.io
        Chromeheadless.io save your time and resources in exporting html, report to PDF.

```

**index.php**

```
require_once "../koolreport/core/autoload.php";
require_once "MyReport.php";

$report = new MyReport;
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio("token-key")
->pdf()
->toBrowser("myreport.pdf");

```

Export engines
--------------

[](#export-engines)

ChromeHeadless.io has three pdf export engines which are headless chrome, wkhtmltopdf, and phantomjs. Here're examples to use them:

```
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio("token-key")
->pdf($chromePDFOptions)
->toBrowser("myreport.pdf");

$report->run()
->cloudExport("MyReportPDF")
->khtml("token-key")
->pdf($khtmlPDFOption)
->toBrowser("myreport.pdf");

$report->run()
->cloudExport("MyReportPDF")
->phantomjs("token-key")
->pdf($phantomjsPDFOption)
->toBrowser("myreport.pdf");

```

Headless chrome has more features but wkhtmltopdf is faster for big files. Phantomjs has the advantage of header and footer callbacks which allow for custom header/footer for each page.

Extra settings
--------------

[](#extra-settings)

You may add some extra settings to guide ChromeHeadless.io to load your page.

```
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio("token-key")
->settings([
    "pageWaiting"=>"load", // load, domcontentloaded, networkidle0, networkidle2
    "useLocalTempFolder" => true,
    "autoDeleteLocalTempFile" => true,
    "serviceHost" => "http://localhost:8000", // default value: https://service.chromeheadless.io
    "serviceUrl" => "http://localhost:8000/api/export",
])
->pdf($chromePDFOptions)
->toBrowser("myreport.pdf");

```

NameTypeDefaultDescriptionAvailable since version`pageWaiting`string"load"When to consider navigation succeeded. Other options are `"domcontentloaded"` page finished when all DOM is loaded; `"networkidle0"` page finished when there are no more than 0 network connections for at least 500 ms; `"networkidle2"` page finished when there are no more than 2 network connections for at least 500 ms.1.0.0`useLocalTempFolder`booleanfalseUse/create a local temporary directory instead of system temporary directory to store temporary export files1.0.0`autoDeleteLocalTempFile`booleanfalseAuto delete temporary export files after exporting1.0.0`serviceHost`stringChoose KoolReport's cloud server or your local export server4.0.0`serviceUrl`string{serviceHost}/api/exportTo be used if you want another export route other than /api/export4.0.0Export options
--------------

[](#export-options)

### PDF for headless chrome engine

[](#pdf-for-headless-chrome-engine)

The `pdf()` method will help to generate pdf file. It takes an array as parameter defining options for your PDF. Below are available options.

NameTypeDefaultDescription`scale`number1Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2`displayHeaderFooter`boolfalseDisplay header and footer.`headerTemplate`stringHTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `pageNumber` current page number; `totalPages` total pages in the document;`footerTemplate`stringHTML template for the print footer. Should use the same format as the `headerTemplate``printBackground`boolfalsePrint background graphics.`landscape`boolfalsePaper orientation.`pageRanges`stringPaper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.`format`stringPaper format. If set, takes priority over width or height options. Defaults to 'Letter'.`width`string/numberPaper width, accepts values labeled with units.`height`string/numberPaper height, accepts values labeled with units.`margin`objectPaper margins, defaults to none. It has 4 sub properties: `top`, `right`, `bottom`, `left` which can take number or string with unitsAll options could be found at this link [Headless Chrome pdf options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions)

**Example:**

```
...
->pdf([
    "scale"=>1,
    "format"=>"A4",
    "landscape"=>true
])
...

```

### PDF for wkhtmltopdf engine

[](#pdf-for-wkhtmltopdf-engine)

All options could be found at this link, section Global Options [Wkhtmltopdf Docs](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt)

**Example:**

```
...
->pdf([
    "--collate"=>true,
    "--page-size"=>"A4",
    "--orientation"=>"Landscape",
    "--margin-top"=>"100px"
])
...

```

### PDF options in view file for both headless chrome and wkhtmltopdf engines

[](#pdf-options-in-view-file-for-both-headless-chrome-and-wkhtmltopdf-engines)

Some pdf options could be set directly in the PDF view file instead of pdf() method.

#### header and footer

[](#header-and-footer)

In the view file, use header and footer tags to set pdf's header and footer template:

**Example:**

```

        Header:
        {date}
        {title}
        {url}
        {pageNumber}
        {totalPages}

...

```

Headless chrome: If either header or footer tag exists, pdf options' displayHeaderFooter will be true. PDF options' headerTemplate and footerTemplate options take priority over view file's header and footer tags. With header and footer tags, if there's no font-size style, a default style "font-size:10x" is used. Header and footer tags supports place holders like {date}, {title}, etc and img tag with link-type src. For img tag pdf options' headerTemplate and footerTemplate only support base64-type src.

```

        {page}{frompage}{topage}{webpage}{section}{subsection}{date}{isodate}{time}{title}{doctitle}{sitepage}{sitepages}

...

```

Wkhtmltopdf: The exact html content of the header and footer tags including img tags will be used as pdf header and footer with some substituted variables.

#### margin

[](#margin)

In the view file, use the body tag's margin style to set pdf margin:

**Example:**

```
//MyReportPDF.view.php

...

```

If either header or footer tag exists but there's no body's margin top or bottom, a default margin top or bottom of 1 inch will be used

#### No template option

[](#no-template-option)

If you don't have any header/footer/margin in your template files, you could speed up pdf generating with `noTemplateOption` property:

```
...
->pdf([
    "noTemplateOption"=>true,
    ...
])
...

```

### JPG for headless chrome

[](#jpg-for-headless-chrome)

The `jpg()` help to generate JPG file. It take an array as parameter defining options for your JPG. Below are list of properties:

NameTypeDefaultDescription`quality`numberThe quality of the image, between 0-100.`fullPage`boolfalseWhen true, takes a screenshot of the full scrollable page.`clip`objectAn object which specifies clipping region of the page. Should have the following fields: `x` is the x-coordinate of top-left corner of clip area, `y` is y-coordinate of top-left corner of clip area, `width` is the width of clipping area and `height` is the height of clipping area.`omitBackground`boolfalseHides default white background and allows capturing screenshots with transparency.`encoding`string"binary"The encoding of the image, can be either `base64` or `binary`**Example:**

```
...
->jpg([
    "quality"=>80
    "clip"=>[
        "x"=>100,
        "y"=>100,
        "width"=>500,
        "height"=>1000,
    ]
])
...

```

### PNG for headless chrome

[](#png-for-headless-chrome)

The `png()` help to generate PNG file. It take an array as parameter defining options for your PNG. Below are list of properties:

NameTypeDefaultDescription`fullPage`boolfalseWhen true, takes a screenshot of the full scrollable page.`clip`objectAn object which specifies clipping region of the page. Should have the following fields: `x` is the x-coordinate of top-left corner of clip area, `y` is y-coordinate of top-left corner of clip area, `width` is the width of clipping area and `height` is the height of clipping area.`omitBackground`boolfalseHides default white background and allows capturing screenshots with transparency.`encoding`string"binary"The encoding of the image, can be either `base64` or `binary`**Example:**

```
...
->png([
    "clip"=>[
        "x"=>100,
        "y"=>100,
        "width"=>500,
        "height"=>1000,
    ]
])
...

```

Get results
-----------

[](#get-results)

In all above examples we use method `toBrowser()` to send the file to browser for user to download. Here are all options:

MethodReturnDescription`toBrowser($filename,$openOnBrowser)`Force user to download file or open the file on browser if `$openOnBrowser` is set to `true``toString()`stringReturn filename as string`toBase64()`stringReturn content of file in base64`saveAs($path)`Save the file to specific location**Examples:**

```
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio("token-key")
->pdf()
->saveAs("../stores/myreport.pdf");

```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Recently: every ~288 days

Total

14

Last Release

643d ago

Major Versions

1.5.1 → 2.0.02021-07-07

2.1.1 → 3.0.02021-07-07

1.3.0 → 4.0.02021-11-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a27c60d0b76ca63f2216334e1e7668bff2b75ef9ffcc601855d738f29e17dab?d=identicon)[koolreport](/maintainers/koolreport)

---

Top Contributors

[![dongnl](https://avatars.githubusercontent.com/u/5791383?v=4)](https://github.com/dongnl "dongnl (26 commits)")[![tuananhnghiem](https://avatars.githubusercontent.com/u/7497712?v=4)](https://github.com/tuananhnghiem "tuananhnghiem (8 commits)")

---

Tags

pdfpdf-exportpdf-generationphp-pdfphp-reporting-toolsreporting-enginephpData ReportReporting Toolspdf exportcloud export servicejpg png export

### Embed Badge

![Health badge](/badges/koolreport-cloudexport/health.svg)

```
[![Health](https://phpackages.com/badges/koolreport-cloudexport/health.svg)](https://phpackages.com/packages/koolreport-cloudexport)
```

###  Alternatives

[daandesmedt/phpheadlesschrome

A PHP wrapper for using Google Chrome Headless mode. Convert URL or HTML to a PDF / screenshot. Easy to use and OOP interfaced.

93250.1k](/packages/daandesmedt-phpheadlesschrome)[koolreport/laravel

Allow to use KoolReport seamlessly in Laravel

18267.8k](/packages/koolreport-laravel)[kiwilan/php-ebook

PHP package to read metadata and extract covers from eBooks, comics and audiobooks.

3517.3k2](/packages/kiwilan-php-ebook)[irebega/docx-replacer

PHP extension that allow you replace text to text or text to image in DOCX file

1434.7k](/packages/irebega-docx-replacer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
