KoolReport's Forum

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

Exporting Form results to PDF #207

Open Stephen Potter opened this topic on on Feb 2, 2018 - 3 comments

Stephen Potter commented on Feb 2, 2018

Hi, I created a form using inputs linked to a database with a Submit button. I also added the Download PDF button to my view based on the Sakila_Rental export example. Only problem I have is that when I click the download to PDF button a PDF is created but there is no data for my ColumnChart, PieChart and Table. How do I ensure that the params or variables are available from my form.view to be able to be used in my formPDF.view? The formPDF view is just the Charts and Table but without all of the input buttons drop downs etc.

Regards S

KoolReport commented on Feb 2, 2018

Please do this:

  1. On the button export, you put onclick="doExport()"
  2. This is the javascript code for doExport() function:
<script type="text/javascript">
function doExport()
{
    var _form = document.getElementById("parameterForm");
    _form.action = "export.php";
    _form.submit();
    _form.action = "index.php";
}
</script>

We assume your form has name of "parameterForm". What we have done here is when user hit export button, the form action will be change to export.php and intead of submitting form to index.php, it submit the export.php to do export. Then later the action is assigned back to "index.php"

Hope that helps.

Stephen Potter commented on Feb 4, 2018

Thanks a lot,

Does the script go in the form? mine is called (Report.view) in the <head>....</head> section? my button is also in the same view.

My setup is

index.php (calls report.php) export.php Report.php (contains my queries to feed the inputs) Report.view.php (form view showing inputs and buttons, pie chart bar chart and table) ReportPDF.view.php (PDF view only contains pie chart, bar chart and Table)

Stephen Potter commented on Feb 5, 2018

OK so I have the export creating a PDF but only the table is showing and not the Bar or Pie Chart. Is there a solution for this?

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