KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

PDF Export failing when HTML document body is missing #1491

Open Advanced Applications GmbH opened this topic on on Jun 18 - 4 comments

Advanced Applications GmbH commented on Jun 18

I've just integrated the PDF export package in my Koolreport installation. But sadly, when I run and export my report to PDF, the underlying PhantomJS executable runs for a long time and then fails with the following result (which I extracted through my debugger from the $result variable in the koolreport\export\Handler->runPhantom() function):

TypeError: null is not an object (evaluating 'document.body.style')

  http://localhost/reportrun.php?reportName=SimpleReport&reportParameterSource=input&VMNameFilter=Test&parameterFileName=MAQ.json&reportExport=pdf:24 in init
  :2
  :3
TypeError: null is not an object (evaluating 'viewSettings.header')

  phantomjs://code/pdf.js:202 in processViewSettings
  phantomjs://code/pdf.js:280 in renderAndExit
  phantomjs://code/pdf.js:294

Now as far as I understand it, the scripts used for the PDF export are looking for the body element as well as div elements with the classes page-header or page-footer respectively. My reports do not have any of these tags in their view files, as they are added by a wrapper file which handles the report execution and is absolutely vital.

Is there a way to circumvent, or alternatively inject, these required HTML tags?

Regards

Marcel

KoolReport commented on Jun 19

Hi, you may separate view for pdf generation and in that view, you have body tag.

Advanced Applications GmbH commented on Jun 19

Okay I did that, but now I'm getting hit with the following error from PhantomJS:

ReferenceError: Can't find variable: pdf_export

  undefined:2
  :3
TypeError: null is not an object (evaluating 'viewSettings.header')

  phantomjs://code/pdf.js:202 in processViewSettings
  phantomjs://code/pdf.js:280 in renderAndExit
  phantomjs://code/pdf.js:294

I've checked the temporary file and it does contain the report with html, head and body tags as expected.

Regards

Marcel

Advanced Applications GmbH commented on Jun 26

Do you have any suggestions regarding the error of my previous post?

KoolReport commented on Jun 29

I suggest that you start with small example to see if export working normally then you gradually adding piece by piece to see if any piece break the exporting. From the error you send, I has not been able to catch what may go wrong so I would only have the above suggestion.

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

Export