Skip to content
Advertisement

Generate Multiple Page TCPDF on Codeigniter

I have a table that i use to show a data and generate a report based on each row. The table would be like this:

JavaScript

this is my controller to generate the pdf so far:

JavaScript

and this is the view:

JavaScript

and here’s my model

JavaScript

I managed to generate a pdf for each row. but is it possible to generate a file with multiple pages based on checked checkbox? could the pdf file generate each data checked with different pages in a file?

Advertisement

Answer

You could do it like below

Front End

Add form tags before and after table tags, set the form target to a new method (allreportpdf), and also add the submit button to trigger the save all report inside the form (maybe before the form close tag) :

JavaScript

Add a name (maybe eid) on checkbox input, it will be used as post data on the new method (allreportpdf).

JavaScript

Back End

Since this page using different layout, you should make a new method on AllowanceReport class, using the prevously set post name (eid), you could use it within a foreach() loop, and modify the pdf setting so each id is separated on each page :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement