{"id":20206991,"url":"https://github.com/koolreport/cloudexport","last_synced_at":"2025-08-22T13:15:09.986Z","repository":{"id":57008481,"uuid":"185561914","full_name":"koolreport/cloudexport","owner":"koolreport","description":"Export your report to PDF, JPG, PNG or other formats using cloud service","archived":false,"fork":false,"pushed_at":"2024-09-20T07:28:46.000Z","size":32,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T11:13:11.391Z","etag":null,"topics":["pdf","pdf-export","pdf-generation","php-pdf","php-reporting-tools","reporting-engine"],"latest_commit_sha":null,"homepage":"https://www.koolreport.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koolreport.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-08T08:11:44.000Z","updated_at":"2024-09-20T07:13:17.000Z","dependencies_parsed_at":"2022-08-21T14:31:22.742Z","dependency_job_id":null,"html_url":"https://github.com/koolreport/cloudexport","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fcloudexport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fcloudexport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fcloudexport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fcloudexport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koolreport","download_url":"https://codeload.github.com/koolreport/cloudexport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065284,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pdf","pdf-export","pdf-generation","php-pdf","php-reporting-tools","reporting-engine"],"created_at":"2024-11-14T05:27:03.712Z","updated_at":"2025-04-10T12:33:16.356Z","avatar_url":"https://github.com/koolreport.png","language":"PHP","readme":"# Introduction\n\n`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.\n\n# Installation\n\n## By downloading .zip file\n\n1. [Download](https://www.koolreport.com/packages/cloudexport)\n2. Unzip the zip file\n3. Copy the folder `cloudexport` into `koolreport` folder so that look like below\n\n```bash\nkoolreport\n├── core\n├── cloudexport\n```\n\n## By composer\n\n```\ncomposer require koolreport/cloudexport\n```\n\n# ChromeHeadless.io\n\n## Overview\n\n__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.\n\n## Get Token Key\n\n1. 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.\n2. Use account credential in welcome email to log in our system.\n3. Go to [tokens management](https://chromeheadless.io/account/tokens) page\n4. Hit `Generate` button to generate token key.\n\n## Example\n\n__MyReport.php__\n\n```\nclass MyReport extends \\koolreport\\KoolReport\n{\n    //Register cloud export service in your report\n    use \\koolreport\\cloudexport\\Exportable;\n}\n```\n\n__MyReportPDF.view.php__\n\n```html\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eThis is my first export using Chromeheadless.io\u003c/h1\u003e\n        \u003cp\u003eChromeheadless.io save your time and resources in exporting html, report to PDF.\u003c/p\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n__index.php__\n\n```\nrequire_once \"../koolreport/core/autoload.php\";\nrequire_once \"MyReport.php\";\n\n$report = new MyReport;\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003echromeHeadlessio(\"token-key\")\n-\u003epdf()\n-\u003etoBrowser(\"myreport.pdf\");\n```\n\n## Export engines\n\nChromeHeadless.io has three pdf export engines which are headless chrome, wkhtmltopdf, and phantomjs. Here're examples to use them:\n\n```\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003echromeHeadlessio(\"token-key\")\n-\u003epdf($chromePDFOptions)\n-\u003etoBrowser(\"myreport.pdf\");\n\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003ekhtml(\"token-key\")\n-\u003epdf($khtmlPDFOption)\n-\u003etoBrowser(\"myreport.pdf\");\n\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003ephantomjs(\"token-key\")\n-\u003epdf($phantomjsPDFOption)\n-\u003etoBrowser(\"myreport.pdf\");\n```\n\nHeadless 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.\n\n## Extra settings\n\nYou may add some extra settings to guide ChromeHeadless.io to load your page.\n\n```\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003echromeHeadlessio(\"token-key\")\n-\u003esettings([\n    \"pageWaiting\"=\u003e\"load\", // load, domcontentloaded, networkidle0, networkidle2\n    \"useLocalTempFolder\" =\u003e true,\n    \"autoDeleteLocalTempFile\" =\u003e true,\n    \"serviceHost\" =\u003e \"http://localhost:8000\", // default value: https://service.chromeheadless.io\n    \"serviceUrl\" =\u003e \"http://localhost:8000/api/export\",\n])\n-\u003epdf($chromePDFOptions)\n-\u003etoBrowser(\"myreport.pdf\");\n```\n\n|Name|Type|Default|Description| Available since version |\n|---|---|---|---|---|\n|`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 |\n|`useLocalTempFolder`|boolean|false| Use/create a local temporary directory instead of system temporary directory to store temporary export files | 1.0.0 |\n|`autoDeleteLocalTempFile`|boolean|false| Auto delete temporary export files after exporting | 1.0.0 |\n|`serviceHost`|string|https://service.chromeheadless.io| Choose KoolReport's cloud server or your local export server | 4.0.0 |\n|`serviceUrl`|string|{serviceHost}/api/export| To be used if you want another export route other than /api/export | 4.0.0 |\n\n\n## Export options\n\n### PDF for headless chrome engine\n\nThe `pdf()` method will help to generate pdf file. It takes an array as parameter defining options for your PDF. Below are available options.\n\n|Name|Type|Default|Description|\n|---|---|---|---|\n|`scale`|number|1|Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2|\n|`displayHeaderFooter`|bool|false|Display header and footer.|\n|`headerTemplate`|string||HTML 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; |\n|`footerTemplate`|string||HTML template for the print footer. Should use the same format as the `headerTemplate`|\n|`printBackground`|bool|false|Print background graphics.|\n|`landscape`|bool|false|Paper orientation.|\n|`pageRanges`|string||Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.|\n|`format`|string||Paper format. If set, takes priority over width or height options. Defaults to 'Letter'.|\n|`width`|string/number||Paper width, accepts values labeled with units.|\n|`height`|string/number||Paper height, accepts values labeled with units.|\n|`margin`|object||Paper margins, defaults to none. It has 4 sub properties: `top`, `right`, `bottom`, `left` which can take number or string with units|\n\nAll options could be found at this link [Headless Chrome pdf options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions)\n\n__Example:__\n\n```\n...\n-\u003epdf([\n    \"scale\"=\u003e1,\n    \"format\"=\u003e\"A4\",\n    \"landscape\"=\u003etrue\n])\n...\n```\n\n### PDF for wkhtmltopdf engine\n\nAll options could be found at this link, section Global Options [Wkhtmltopdf Docs](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt)\n\n__Example:__\n\n```\n...\n-\u003epdf([\n    \"--collate\"=\u003etrue,\n    \"--page-size\"=\u003e\"A4\",\n    \"--orientation\"=\u003e\"Landscape\",\n    \"--margin-top\"=\u003e\"100px\"\n])\n...\n```\n\n### PDF options in view file for both headless chrome and wkhtmltopdf engines\n\nSome pdf options could be set directly in the PDF view file instead of pdf() method.\n\n#### header and footer\n\nIn the view file, use header and footer tags to set pdf's header and footer template:\n\n__Example:__\n\n```\n\u003c!-- Headless chrome pdf template --\u003e\n\u003cheader\u003e\n    \u003cdiv id=\"header-template\" \n        style=\"font-size:10px !important; color:#808080; padding-left:10px\"\u003e\n        \u003cspan\u003eHeader: \u003c/span\u003e\n        {date}\n        {title}\n        {url}\n        {pageNumber}\n        {totalPages}\n        \u003cspan id='pageNum' class=\"pageNumber\"\u003e\u003c/span\u003e\n        \u003cimg src='http://www.chromium.org/_/rsrc/1438879449147/config/customLogo.gif?revision=3' /\u003e\n    \u003c/div\u003e\n\u003c/header\u003e\n\u003cfooter\u003e\n...\n\u003c/footer\u003e\n```\nHeadless 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.\n\n```\n\u003c!-- Wkhtmltopdf pdf template --\u003e\n\u003cheader\u003e\n    \u003cdiv\u003e\n        {page}{frompage}{topage}{webpage}{section}{subsection}{date}{isodate}{time}{title}{doctitle}{sitepage}{sitepages}\n    \u003c/div\u003e\n\u003c/header\u003e\n\u003cfooter\u003e\n...\n\u003c/footer\u003e\n```\n\nWkhtmltopdf: 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.\n\n#### margin\n\nIn the view file, use the body tag's margin style to set pdf margin:\n\n__Example:__\n\n```\n//MyReportPDF.view.php\n\u003cbody style='margin: 1in 0.5in 1in 0.5in'\u003e\n...\n\u003c/body\u003e\n\n```\nIf 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\n\n#### No template option\n\nIf you don't have any header/footer/margin in your template files, you could speed up pdf generating with `noTemplateOption` property:\n\n```\n...\n-\u003epdf([\n    \"noTemplateOption\"=\u003etrue,\n    ...\n])\n...\n```\n\n### JPG for headless chrome\n\nThe `jpg()` help to generate JPG file. It take an array as parameter defining options for your JPG. Below are list of properties:\n\n|Name|Type|Default|Description|\n|---|---|---|---|\n|`quality`|number||The quality of the image, between 0-100.|\n|`fullPage`|bool|false|When true, takes a screenshot of the full scrollable page.|\n|`clip`|object||An 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.|\n|`omitBackground`|bool|false|Hides default white background and allows capturing screenshots with transparency. |\n|`encoding`|string|\"binary\"|The encoding of the image, can be either `base64` or `binary`|\n\n__Example:__\n\n```\n...\n-\u003ejpg([\n    \"quality\"=\u003e80\n    \"clip\"=\u003e[\n        \"x\"=\u003e100,\n        \"y\"=\u003e100,\n        \"width\"=\u003e500,\n        \"height\"=\u003e1000,\n    ]\n])\n...\n```\n\n\n### PNG for headless chrome\n\nThe `png()` help to generate PNG file. It take an array as parameter defining options for your PNG. Below are list of properties:\n\n|Name|Type|Default|Description|\n|---|---|---|---|\n|`fullPage`|bool|false|When true, takes a screenshot of the full scrollable page.|\n|`clip`|object||An 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.|\n|`omitBackground`|bool|false|Hides default white background and allows capturing screenshots with transparency. |\n|`encoding`|string|\"binary\"|The encoding of the image, can be either `base64` or `binary`|\n\n__Example:__\n\n```\n...\n-\u003epng([\n    \"clip\"=\u003e[\n        \"x\"=\u003e100,\n        \"y\"=\u003e100,\n        \"width\"=\u003e500,\n        \"height\"=\u003e1000,\n    ]\n])\n...\n```\n\n\n## Get results\n\nIn all above examples we use method `toBrowser()` to send the file to browser for user to download. Here are all options:\n\n|Method|Return|Description|\n|---|---|---|\n|`toBrowser($filename,$openOnBrowser)`||Force user to download file or open the file on browser if `$openOnBrowser` is set to `true`|\n|`toString()`|string|Return filename as string|\n|`toBase64()`|string|Return content of file in base64|\n|`saveAs($path)`||Save the file to specific location|\n\n__Examples:__\n\n```\n$report-\u003erun()\n-\u003ecloudExport(\"MyReportPDF\")\n-\u003echromeHeadlessio(\"token-key\")\n-\u003epdf()\n-\u003esaveAs(\"../stores/myreport.pdf\");\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Fcloudexport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoolreport%2Fcloudexport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Fcloudexport/lists"}