KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

CloudExport get_file_contents #3239

Open Adolfo Alonso opened this topic on on Feb 7 - 1 comments

Adolfo Alonso commented on Feb 7

Hello, I need to make a PDF file to be sent over email every day, I first tried using the export feature but apparently this does not support DataTable header to be repeated on every page (this is a must). So now I'm trying using CloudExport, but get the following error:

Warning: file_get_contents(http://localhost/koolreport/datagrid/DataTables/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAK2SURBVFgJ7ZY9j41BFICvryCExrJBQ6HyEYVEIREaUZDQIRoR2ViJKCioxV+gkVXYTVZEQiEUhG2EQnxUCh0FKolY4ut5XnM2cyfva3Pt5m7EPcmzZ2bemTNnzjkzd1utnvQi0IvAfxiBy5z5FoxO89kPY+8mbMjtzs47RXs5/WVpbAG6bWExt5PuIibvhVkwmC+ck3eK9ln6/fAddFojYzBVuYSBpcnIEvRaqOw2RcaN18FPuJH0JvRUxbT3wWf4ltiKPgfVidWlbGZgPozDFfgAC+EA/K2EI4cwcAJ+gPaeQ+VQU2SOMMGcPgPl/m/V2p50rrbRsRgt9Iv5h6xtpP22Bz7Ce1C+gFFxfKzOmShcU+Qmyh2w3w8rIJfddHTck66EukL/xPhj+JM8rHNmFys0Pg4v0up3aFNlwR9NYyodd3OL/C64zpsymcTFcf6ElM4YzjAWKYrJkaq8kE/yUYNP4BoYvS1QRo+hNtF5xfkTUjoTheukSFFMjlTFm6PjceOca/SMpKfeCR1L6Uzk/y2WIkVhNFJlJAZhP+hYns7b9D3IPuhY5mYrIv8OrQJvR5NYyNaW4jsU8pSGNySiVx4o5tXq3JkoXE/mg5R/M8dGJCJpKhaDcjBRdbI/Rm8g69c122om33BHmj2CHoV5qa9jUXBraJ+G1fAVjIBO1klc87ro1K4JZ/K35SWW3TwcyDd6TecqnAEd8cGq2+w84xvBm1n3vS0izKkkwh5XNC/GmFPqqAtPF89AOScKuemaNzoTV1SD5dtSbmLf1/RV+tC0WTgcj6R7HEtrVGWaqu/lYDZ/2pvxQ/kIyw/gFByHC9AHw910hv1aUUumyd8yy0QfhmEkfiNod0Xusct68J1qc8Tdux0Z97Q+hsDb+AYGYEbF/4Guw2Q/qDPqZG/zXgT+3Qj8AtKnfWhFwmuAAAAAAElFTkSuQmCC): Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 15

Warning: file_get_contents(http://localhost/koolreport/datagrid/DataTables/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAG5SURBVEgN3VU9LwVBFF0fiYhofUSlEQkKhU7z/oBCQkIiGr9BgUbhVzy9BAnhFyjV/AYFiU5ICM7ZN+c5Zud5dm3lJmfmzrkz9+7cu3c3y/6jjOBSF8CxXS7FmTkbwqIJjDpJvTcmsJ4K3KPZUpyZsx0sxoB9J6mnAkyC7wGuuCFIipNtEcpcWExgXpOBc78vgj6N+QO4NVsjwdFM59tUIDxDrHMBOeIQ34C5ZDregXuAQm4YcI68nN9B3wr2PcwPAIPkN2EqtJH6b+QZm1ajjTx7BqwAr26Lb+C2Kvpbt0Mb2HAJ7NrGFGfmXO3DeA4UshDfQAVmH0gaUFg852TTTDvlxwBlCtxy9zXyBhQFaq0wMmIdRebrfgosA3zb2hKnqG0oqchp4QbuR8X0TjzABhbdOT8jnQ/atcgqpnfwOA7yqZyTU587ZkIGdesLTt2EkynOnbreMUUKMI/dA4B/QVOcO13CQh+5wWCgDwo/75u59odB/wjmfhbgvACcAOyZPHihMWAoIwxyCLgf1oxfgjzVbgBXSTzIN+f0pg6s5DkcesLMRpsBrgE2XO3CN64JFP7JtUeKHX4CKtRRXFZ+7dEAAAAASUVORK5CYII=): Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 15

Warning: file_get_contents(http://localhost/koolreport/datagrid/DataTables/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAEnSURBVCgVpdG7SgNBFIDh1RhJsBBEsDIgIhaWFjZa2GtpKb6AnU0MprKOWEjK2IuFFxCxS2lhZyOWXh5AQVER/X+zuwwywoIHvp3dM3Nm55Ik/4i+P2or5FewiBIe0cEt8ogVz9LbhEVf+cgkcew1tvAZ5PPXGm9HOMEanMAYQhunaCAazuqA1UjvILl9HGPc/n4fabjPGbzjMM2FjfkDuPw5O8JilzgA9/OKWDynyWnbsPiF7yc4SRWxmEyTN7ZhsSd7gTLW8TuGSSzBcZd2hsV+n+MNC9jGCNzjPDwsz8XCO/x02Bqeptcxhg+4gjD8YxetLOkBGRbuwcIr+NdRLMPl3uMM2YHx2gsLd+D97qKEQuGe65jCAzbgVRWOCUZuovAfs5m/AdVxL0R1AIsLAAAAAElFTkSuQmCC): Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 15

Fatal error: Uncaught Error: Class "ZipArchive" not found in C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php:64 Stack trace: #0 C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php(320): chromeheadlessio\Exporter->zipWholeFolder('C:\\Users\\ADOLFO...', 'C:\\Users\\ADOLFO...') #1 C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php(387): chromeheadlessio\Exporter->saveTempContent('<script type='t...') #2 C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Service.php(35): chromeheadlessio\Exporter->cloudRequest('pdf', Array) #3 C:\xampp\htdocs\koolreport\cloudexport\ChromeHeadlessIoService.php(119): chromeheadlessio\Service->pdf(Array) #4 C:\xampp\htdocs\koolreport\cloudexport\ChromeHeadlessIoService.php(79): koolreport\cloudexport\ChromeHeadlessIoService->exportTo('pdf', Array) #5 C:\xampp\htdocs\reportes\RAV\cloudpdf\index.php(8): koolreport\cloudexport\ChromeHeadlessIoService->pdf() #6 {main} thrown in C:\xampp\htdocs\koolreport\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 64

I have also tried using ->settings(array('useLocalTempFolder' => true)) but get the same error, some files are appearing in the tmp folder but no PDF.

Index.php

<?php
require_once "MyReport.php";
$report = new MyReport;
$report->run();
$report->cloudExport("MyReport")
->chromeHeadlessio("XXX")
->settings(array('useLocalTempFolder' => true))
->pdf()
->toBrowser("MyReport.pdf");

MyReport.php

<?php
	// Require autoload.php from koolreport library
	require_once "../../../koolreport/core/autoload.php";
	
	//Step 2: Creating Report class
	class MyReport extends \koolreport\KoolReport
	{
		use \koolreport\amazing\Theme;
		use \koolreport\inputs\Bindable;
		use \koolreport\inputs\POSTBinding;
		use \koolreport\cloudexport\Exportable;
		
			protected function defaultParamValues()
			{
				return array(
					"dateRange"=>array(
						date("Y-m-d", strtotime('-7 days')) . " 00:00:00",
						date("Y-m-d", strtotime('-0 days')) . " 23:59:59"
					),
					"unidad"=> "",
				);
			}
			
			protected function bindParamsToInputs()
			{
				return array(
				"dateRange"=>"dateRange",
				"unidad"=>"unidad"
				);
			}
		
		public function settings()
		{
			return array(
				"dataSources"=>array(
						"automaker"=>array(
						'host' => 
						'username' =>
						'password' => 
						'dbname' => 
						'charset' => 'utf8',  
						'class' => "\koolreport\datasources\MySQLDataSource"  
					),
				)
			);
		}
	    public function setup()
	    {
            $query="
			SELECT
			XXXX
			ORDER BY c.sucursalid, c.fecha_ingreso;
			";
            $this->src('automaker')
            ->query($query)
            ->params(array(
				":unidad" => 	$this->params["unidad"],
                ":start"=>		$this->params["dateRange"][0],
                ":end"=>		$this->params["dateRange"][1]
            ))
            ->pipe($this->dataStore('validacion'));

	    }
    }

MyReport.view

<?php 
    use \koolreport\inputs\Select2;
	use \koolreport\inputs\DateRangePicker;
    use \koolreport\chartjs\ColumnChart;
	use \koolreport\datagrid\DataTables;
	date_default_timezone_set("America/Mexico_City");
	$dt = date('dmYHi');
?>
 <style type="text/css">
  <?php if ($this->params['visualization'] === 'table' && !empty($this->params['colors'])): ?>
	.tableColor
	{
		background-color:<?php echo $this->params['colors'][0] . '!important' ?>;
	}
  <?php endif; ?>
</style>
<head>
	<title>Reporte RAV</title>
</head>
<div class="container-fluid app-container">
	<div style="margin-bottom:20px;"></div>	
	<div class="card card-accent-primary">
		<div class="card-body smart-title">
			<div class="doc-content"><h1>Reporte RAV</h1>
				<p>V.0</p>
				<div class="row">
					<div class= "col-md-12 form-group">
						<?php 
						DataTables::create(array(
							"dataSource"=>$this->dataStore("validacion"),
							'cssStyle'=>array(
								'td' => function($row, $colName) {
									if($colName === 'score' && $row['score'] > 1) {return 'background-color: #FFCCCB';}
								},
							),
							"options"=>array(
								"order"=>array(
									array(0,"asc")),
								"fixedHeader"=>true
							),
							"columns"=>array(
								"sucursal"=>array(
									"type"=>"string",
									"label"=>"Sucursal"),
								"nombre"=>array(
									"type"=>"string",
									"label"=>"Nombre"),
								"mes"=>array(
									"type"=>"string",
									"label"=>"Mes"),
								"kms"=>array(
									"type"=>"number",
									"label"=>"Kms"),
								"abrusca"=>array(
									"type"=>"number",
									"label"=>"Acel. Brusca"),
								"abrusca100"=>array(
									"type"=>"number",
									"label"=>"Acel. Brusca / 100 kms",
									"decimals"=>2),
								"fbrusco"=>array(
									"type"=>"number",
									"label"=>"F. Brusco"),
								"fbrusco100"=>array(
									"type"=>"number",
									"label"=>"F. Brusco / 100 kms",
									"decimals"=>2),
								"evel"=>array(
									"type"=>"number",
									"label"=>"Exceso Velocidad"),
								"eveldur"=>array(
									"type"=>"string",
									"label"=>"Exc. Vel. Dur"),
								"eveldur100"=>array(
									"type"=>"number",
									"label"=>"Seg / 100 kms",
									"decimals"=>2),
								"score"=>array(
									"type"=>"number",
									"label"=>"Score",
									"decimals"=>2),
								),
							"cssClass"=> array(
								"td" => "text-center",
								"th" => "text-center",
							),
						)
						);
						?>
					</div>
				</div>
			</div>	
		</div>
	</div>
</div>
Sebastian Morales commented on Feb 15

It's not the warning but the last error that causes the issue. Pls install PHP zip extension on your server/localhost and try cloud export again. Rgds,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None