Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
I have set max_execution_time = 300 in the php.ini file.
AS you mentioned in the previous comment, I have tried the simple report view and now getting uncaught Exception like Could not save content to a temporary folder. Actually, I want to display the PDF file on the browser so used below code
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio($secretToken)
->pdf()
->toBrowser("myreport.pdf");
Can you help to resolve the issue?
Hi Mike,
By default, cloud export use system temp folder to save temporary files. If you had trouble saving temporary files (often it's a permission issue) please try to use a local temporary folder with this option:
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio($secretToken)
->settings([
"useLocalTempFolder" => true,
])
->pdf()
->toBrowser("myreport.pdf");
Let us know how it works for you. Thanks!
Hi Mike,
Please check to see if there's a "tmp" folder in your report folder. If there's one, please try to run a php file with this simple command to see if it returns any error:
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
file_put_contents($pathToTmp . "/test.txt", "Hello world");
Hi David,
I have tried the above mentioned php code and its working fine. It's created the test.txt file in the tmp folder.
Actually the tmp folder is not a issue. The processing file export.html is generated in the tmp folder but there is no content in it. Also, I have checked the chromeheadlessio/php-client/src/Exporter.php file for the tmp folder path and file content. The tmp folder path is like F:\xampp\htdocs\pos\tmp. But when I uncommented below lines in the Exporter.php file to get the content , its empty.
echo ($content);
echo htmlentities($content);
exit();
Can you check these details and advise?
It's my mistake that earlier html content is not coming. Now am able to get the content.
But now the cloud export is taking long time for execution and getting error "Maximum execution time of 300 seconds exceeded". As mentioned by you earlier, am using the small file content like
<html>
<body>
<h1>This is my first export using Chromeheadless.io</h1>
<p>Chromeheadless.io save your time and resources in exporting html, report to PDF.</p>
</body>
</html>
Also, I have checked the tmp folder and found that there are like 1000 javascript files generated. When I checked one of these js file, its showing content of our website login page. As we are generating all these reports based on user access like admin and normal user, so need to maintain user session. Is there any way to send the user authentication details in the curl call in Exporter.php script?
Can you suggest any solution for it?
Hi Mike,
I think that your site first requires some login page, then uses some token in request header for authorization. To solve this problem I would suggest you you create a php file with some functions like this:
<?php
//curlFiles.php
if (! isset($_SESSION["loginToken"])) {
$loginToken = login($userName, $password); //replace $userName and $password with yours
$_SESSION["loginToken"] = $loginToken;
}
function login($userName, $password) {
//use curl with $userName, $password to get response's token
...
return $loginToken;
}
function curlFile($url) {
$loginToken = $_SESSION["loginToken"];
//use curl with $loginToken in header to get the url
...
return $urlContent;
}
Then in your export.php page, include this curlFiles.php and open Exporter.php and replace this line:
$fileContent = file_get_contents($url);
with:
$fileContent = curlFile($url);
I don't know enough about your site's login working for a more detail outline but curl could imitate most complicated requests so if your browser can retrieve the js/css files curl can, too. Let us know if you meet any difficulty. Thanks!
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo