createPDF v. 1.10 failing on new install

9 posts by 3 authors in: Forums > CMS Builder
Last Post: July 24   (RSS)

I have migrated a previously existing website to a new server. Our use of the createPDF plugin on the old site worked well.

When it failed on the new server, I installed the latest version of the plugin, downloaded the available binaries and then specified the best one at the top of createPDF.php

$GLOBALS['CREATEPDF_BINARY_FILE'] = 'wkhtmltopdf-0.12.6-1.debian9_stretch_amd64';

After this, running the test within the plugin comes up green everywhere, suggesting that all should be well.

However, all my calls to the plugin in my application fail with the error:

"Exit with code 1 due to network error: ContentNotFoundErrorError executing wkhtmltopdf! (Exit code: 1)<br>"

My web host is uninterested in helping with software issues, so I was wondering if anyone has any insight into this problem?

Sorry. Realized I should have posted this in the plugins forum!

I have read about this error and have removed relative p[aths from my html but this has not solved anything.

Has anyone else encountered this issue?

Hello pgplast,

It seems you are on the right track and this error seems to be involving one of many scenarios...

  1. It is a relative URL that it is having trouble with
  2. It is running across a link which is broken or the resource is not available (like missing a linked file or something like a font file)
  3. If a link is returning something like a 403 response (forbidden) 
  4. It is choking on some JavaScript (but this seems to be a bit of an outlier)

I think what might help is to show us what is the HTML you are trying to convert and perhaps we can see something you are missing.

I guess the wkhtmltopdf can be a bit finicky at times and so something minor could be the problem. I am guessing that if you had it working before on the other server, perhaps you missed transferring a file to the new server or the new server is not allowed to access something that the original server could. I would start with the HTML you are trying to convert and work from there. :)

Tim Hurd
Senior Application Developer
TimHurd.com

Hi pgplast,

So what you show there is the PHP code used to generate the HTML. Do you have this page hosted on the public web so we can visit it? I think what we need to see is the resulting HTML generated by this PHP. I am assuming that the script looks at the resulting HTML code and uses that to build the PDF. If the PHP generates a relative link or a link that is pointing to a file that doesn't exist, it may then have the issue. If we can see the page up on the new server, we can look at the source code and see if there are any links/resources there that may be an issue.

Hopefully you get what I am saying. :)

Tim Hurd
Senior Application Developer
TimHurd.com

Thanks for the reply, Tim.

Al the pages that give access to these functions require user authentication. I will open a secod. level request so I can share credentials.

I have tried this with both v 1.09 and v 1.10 of createPDF and both fail.

Interestingly, v. 1.09 continues to work flawlessly on our old,server, and the pages that work there are the same ones that fail on the new server. I didn't change any of the code, so it would seem to suggests a difference in server setting.

I have been over it with the web host, (LiquidWeb), but no joy.

Hope you'll be able to see something when I submit for 2nd level.... and thanks.

Hi pgplast, 

CreatePDF works by using the wkhtml2pdf binary to make a browser request for a page and then turning it into a PDF.

However, the way your web server is setup, it has both an external IP address and hostname (the one we all use) and a private internal IP address used only inside the web hosting company's network.   The server is configured to disallow any internal requests to its external IP.  Sometimes this prevents things from working at all, but in your case, we can still make a request to the web server via its internal IP address.  The way to do this is to add this line at the bottom to createPDF.php:

// Note: If this doesn't work try https:// or finding the server's internal IP with 127.0.0.1, $_SERVER["LOCAL_ADDR"], `ipconfig /all`,
// ... or `ifconfig -a` or ask server admins for server's internally accessible  hostname
//$GLOBALS['CREATEPDF_TEMPDIR_URL']       = "http://" . @$_SERVER['HTTP_HOST'] . dirname(@$_SERVER['SCRIPT_NAME']);
$GLOBALS['CREATEPDF_TEMPDIR_URL']       = "https://" . @$_SERVER['SERVER_ADDR'] . dirname(@$_SERVER['SCRIPT_NAME']);

Can you test now?  I think that might fix it for you.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

Dave:

Thanks so much. You solved it, (as expected).

You guys provide the best support ever!

Hey that is awesome pgplast! I learned something new as well. Great to see you got it working.

Tim Hurd
Senior Application Developer
TimHurd.com