psliwa / PHPPdf

Pdf and graphic files generator library written in php
http://ohey.pl
MIT License
339 stars 77 forks source link

Long table, slow render #67

Open amcastror opened 10 years ago

amcastror commented 10 years ago

Hi,

I'm rendering a table with 250 lines, using a tag, but it takes enough time to exceed allowed execution time. The issue is that rendering the information of the table without the html tags (table, tr and td) takes 10 times less time than rendering the hole thing. The result (with tags) is a 14 page pdf.

The problem is solved if I use a tag and break the page myself, but this doesn't really work for me.

The cache is turn on by the way.

Any ideas? Thanks a lot!

aledeg commented 10 years ago

Please show your code.

aledeg commented 10 years ago

I have a project with huge tables. My max_execution_time is 30 seconds and I can render tables with almost 1000 lines. I hit a different problem with tables with more than 20000. It is not a timeout but a memory problem.

franciscotfmc commented 10 years ago

I'm having some issues with execution time too. Can't render a table with more than 200 lines. What's your aproach to render a 2000 lines report, do you render many files and then concat them?

amcastror commented 10 years ago

I found out that using "page" instead of "dynamic-page" did render the view, but you need to estimate when to insert a new block (page break). It's not the best solution, but it works for now. ᐧ

Saludos,

On Mon, Oct 6, 2014 at 2:12 PM, Francisco notifications@github.com wrote:

I'm having some issues with execution time too. Can't render a table with more than 200 lines. What's your aproach to render a 2000 lines report, do you render many files and then concat them?

— Reply to this email directly or view it on GitHub https://github.com/psliwa/PHPPdf/issues/67#issuecomment-58051851.

franciscotfmc commented 10 years ago

Thank you amcastror, I'm gonna try that now. The cons of this page tag is that the pagination won't work out of the box, I guess. But if it renders the 2000 lines, it will worth the loss.

amcastror commented 10 years ago

Glad it helped. If I find a better approach I'll post it here. Good luck. ᐧ

Saludos,

On Mon, Oct 6, 2014 at 3:40 PM, Francisco notifications@github.com wrote:

Thank you amcastror, I'm gonna try that now. The cons of this page tag is that the pagination won't work out of the box, I guess. But if it renders the 2000 lines, it will worth the loss.

— Reply to this email directly or view it on GitHub https://github.com/psliwa/PHPPdf/issues/67#issuecomment-58069472.

franciscotfmc commented 10 years ago

@aledeg What did you do with the memory problem? I think I'm having the same problem now. The more "divs" I use, higher is the probability of a PHP fatal error, trying to allocate more memory than it's allowed.

Thanks in advance

psliwa commented 10 years ago

I will look closer to this issue and try to optimize table support algorithm, but I can not tell when you can expect the results.

franciscotfmc commented 10 years ago

In fact, I'm not using table anymore. Just a bundle of divs with float left and right. I think I'll have to split the generated files in more than one.

aledeg commented 10 years ago

@franciscotfmc I did nothing. I need to solve that problem too. But as it occurs no so often, it is not critical. FYI it happens only once in the past year

franciscotfmc commented 10 years ago

Hello guys,

Just FYI, the timeout issue was solved removing the table tag and maximizing the php time limit to 240. The memory leak I could manage as @amcastror suggested, removing the dynamic-page and manually calculating the paginations, now using he page tag.

Thank you for the help!

noetix commented 9 years ago

I had this problem and solved it by chunking out the data into groups of 20 (or whatever fits nicely on a page) and created a new table for each set. This also solves having a <thead> section on each page.

Surprisingly this increased performance quite a bit.