Skip to content

Performance problem since html2pdf 4.0.3 => 5.0.1 #230

@michauk

Description

@michauk

Hello there,
I upgraded from html2pdf 4.0.3 to latest 5.* some days ago. On a Debian standard server (php 5.6...), in order to prepare the Debian upgrade (from Jessie to Stretch, I'm a bit late). I think I read somewhere that I had to upgrade html2pdf to 5 to get it running on php 7. In any case, it surely is a good thing to upgrade this tool along with the distro.

I encountered a big performance problem I didn't have before.

Mainly, my PDF is a [sometimes] big table (many rows, a few columns) with basic stuff in it (amount, date, reference...)
With html2pdf 5, I need 1.5-2 seconds to generate that table (1 page) for only ~70 lines. Time increases exponentially with the number of lines (the server is a big one with, no performance problem, tuning/monitoring it myself blah blah blah).

  • Approx. 40 seconds for 194 lines.
  • Timeout after 10 minutes for ~1000 lines.
    Before that, for approx. 3000 lines, I needed a few seconds (maybe 5 or 10, I don't remember, but it was reasonnable).

I started to debug this and reduced a copy of my code to just this table with no PHP/mysql processing, I just copied/pasted my table content. I activated setDebugMode to check.

Maybe I missed something simple (or my html code is dirty?), but I can't find why. I tried to remove every style attribute, it's a bit faster, but still slow and exponentially slower.
If anyone has any idea, I'd appreciate.

Here you can find an example with only this table content (+ a footer) with the style attributes (I put it on all TD which is maybe a bad idea. And the same without any style nowhere.
You can copy/paste some TR/TD some generate hundreds of lines and check the processing time.

examples.zip

Regards,
Jacques M.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions