Slow performance

228 views
Skip to first unread message

Raul Diaz

unread,
Jul 19, 2016, 9:01:56 PM7/19/16
to dompdf
Hello, 
Im working wth dompdf v 0.7.0. Working in local server it works perfectly. It generates the pdf and it downloads the document instantly, but when I try in the remote server it itakes around 2-3 minutes to download the pdf. 
I dont stream the pdf file, intead I save the file, and then, I redirect the user to the file, but it still takes too long to use it. This is the code I use to generate the pdf:

__________________________________________________

<style>
    @page {
      margin-top: 0em;
      margin-left: 0.6em;
      margin-right: 0em;
      margin-bottom: 0em;
    }
</style>
    <img src="img/mypic-a4.png">
    <h1 style = "position: absolute;
      left: 0px;
      top: 203px;
      text-align: center;
      width: 100%;
      font-family: helvetica;
      font-size: 26px;
      color: #353430;"> My text </h1>
    <h1 style = "position: absolute;
      left: 0px;
      top: 497px;
      text-align: center;
      width: 100%;
      font-family: helvetica;
      color: #353430;"> My Text </h1>
      <h1 style = "position: absolute;
      left: 63px;
      top: 712px;
      text-align: left;
      width: 100%;
      font-family: helvetica;
      font-size: 10px;
      color: #353430;"> My Text </h1>
_______________________________________________________

Any idea? 

BrianS

unread,
Jul 19, 2016, 9:09:14 PM7/19/16
to dom...@googlegroups.com
That's the extent of your HTML that takes 2-3 minutes? What kind of image is that? We've seen some issues with B/W images that were extremely slow to process.

Raul Diaz

unread,
Jul 20, 2016, 5:44:38 AM7/20/16
to dompdf
This code is the complete HTML to convert. It takes around 2-3 minutes when working in the remote server, but if I work in the local server it takes just 1-2 seconds.

It is a png image of an A4 sheet size. It is a coloured picture and it size is 240 kb. 1103x789 in pixels.

Thanks in advance  :)

John Bell

unread,
Jul 20, 2016, 6:54:10 AM7/20/16
to dom...@googlegroups.com
Hi Raul

If you're seeing a large performance difference between the local and server based versions, I would check the version of PDF between the server and local machines. Also look at the library versions: GD library, zlib, libpng etc...

Regards

John
--
You received this message because you are subscribed to the Google Groups "dompdf" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dompdf+un...@googlegroups.com.
To post to this group, send email to dom...@googlegroups.com.
Visit this group at https://groups.google.com/group/dompdf.
For more options, visit https://groups.google.com/d/optout.

BrianS

unread,
Jul 20, 2016, 6:42:27 PM7/20/16
to dompdf
So first try taking out the image. That seems to be the likely culprit. If it is would it be possible to upload the image so we can take a look at it?

As John said, the versions of the various libraries on your server will be relevant if it's a graphics processing issue. So if you can provide that information it would also help.

Raul Diaz

unread,
Jul 21, 2016, 8:23:21 AM7/21/16
to dompdf
Hello, we have been working on this issue a bit. 
The libaries in the local machine and in the server are the same. 
We have tried to render the pdf file without the picture, and it works perfectly in 1-2 seconds.
We have tried with different image formats (png, jpg, gif) and it takes 2-3 minutes in every case.
We have been doing some investigations, and we have seen that it spends all the time in this piece of code (in dompdf/src/Dompdf.php):


foreach ($this->tree->get_frames() as $frame) {
            // Set up the root frame
            if (is_null($root)) {
                $root = Factory::decorate_root($this->tree->get_root(), $this);
                continue;
            }

            // Create the appropriate decorators, reflowers & positioners.
            Factory::decorate_frame($frame, $this, $root);
        }


We also this it could be a problem from the loading process for the picture, I mean, the main diference between the local environment and the remote server is that in remote server we use https protocols and in local machine just http. 

Thanks in advance :)

BrianS

unread,
Jul 26, 2016, 1:29:52 PM7/26/16
to dompdf
The frame loop there is the main loop for building the document, so it's not surprising a lot of time is spent there. Part of that would be fetching the image, which appears to be the issue (though hard to say right now if the problem is in fetching the image or parsing the image).

So a few things you can try to see if the problem is with fetching the image or processing the image.
  1. Load the picture on the server using HTTP instead of HTTPS.
  2. Write a simple PHP script that uses file_get_contents() to fetch the image over HTTPS.
  3. Load the image from the local file system instead.
  4. Embed the image in the document as a data-uri.
Are the two servers identical otherwise? Maybe a problem writing to the temporary directory?
Reply all
Reply to author
Forward
0 new messages