KoolReport's Forum

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

Phantom js displaying the whole html page as output #815

Open iRiyada opened this topic on on Apr 18, 2019 - 3 comments

iRiyada commented on Apr 18, 2019

Dear sir, I have a datatable which I am filtering using javascript. I have a pdf button which converts webpage to pdf using phantomjs. But it generates the whole report. and not the filtered one. I want pdf report to contain only the filtered data in my datatable. I have filtered using jquery. Is it possible with phantomjs?

KoolReport commented on Apr 19, 2019

If you want to export only filtered data, you need to post the filter to report so that report will run with those filter and produce filtered result before export.

This example may help. Input & Export

iRiyada commented on Apr 22, 2019

My case is different from the above example. I have written a javascript to render datatable report dynamically. The code of the report is given below. Phantom js does'nt execute javascript part. Is there any way in which I can run this javascript during pdf generation?

// ArrayReportPdf-page i want to generate pdf
<body>
<div class="container">
<div style="text-align:center">
<h1>بيان المهام الجارية</h1>
</div>
</div>
</body>
<script>
    window.onload = function(){
var divElements= localStorage.getItem("storageName")//getting the  displayed rows of datatable element
var z = document.createElement('div'); 
z.innerHTML = divElements;
document.body.appendChild(z);// appending to this body tag
console.log(divElements);
    };
</script>
``
Except script everything else is rendering
iRiyada commented on Apr 22, 2019

This is the exportController.php

<?php
namespace App\Http\Controllers;

use App\Reports\ArrayReport;
class exportController extends Controller
{
    public function index()
    {
$report = new ArrayReport;

$report->run()
->export('ArrayReportPdf')
->settings(array(
   // "useLocalTempFolder"=>true,
    //"phantomjs"=>"C:/xampp/htdocs/laravelKoolDelayed/vendor/koolphp/koolreport/packages/export/bin/phantomjs",
    "resourceWaiting"=>2000,
))
->pdf(array(
    "format"=>"A4",
    "orientation"=>"portrait",
    //"zoom"=>2
))
->toBrowser("ArrayReport.pdf");

}
}

   
    
       

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
None yet

None