createPDF question

By kovali - November 14, 2013

Hi, I would like to have a link at the bottom on every detailpage like: "Print page as PDF"

When clicked the detailpage will become available as PDF.

Can anybody put me in the right direction with a short example on how this is done pls, what code to use ??

I've been looking in the documentation and forum but can't figure out how to code this...

Thanks, any help is much appreciated !!

Koen

By kovali - November 14, 2013

Okay I found the info in the readme.txt file... sorry.

But now I get this error message when I click the link to display the page as PDF:

/home/vdwproje/public_html/beheer/plugins/wkhtmltopdf/wkhtmltopdf-i386: symbol lookup error: /home/vdwproje/public_html/beheer/plugins/wkhtmltopdf/wkhtmltopdf-i386: undefined symbol: FcFreeTypeQueryFace

Any ideas what this is all about pls ??

By Dave - November 14, 2013

Hi Kitka, 

It sounds like it's related to this bug related to the wkhtmltopdf linux binary program that createPDF uses to create PDFs: https://code.google.com/p/wkhtmltopdf/issues/detail?id=352

  • Can you see if the error happens even on simple pages without CSS?  Or is it just on pages with CSS?
  • If you have CSS like this loaded by your page such as this "@font-face" try and remove it, or don't load that when displaying PDFs
  • If neither of those things work, see if your server admin can upgrade fontconfig with this command: yum install fontconfig

Hope that helps, let me know what you find out.  Thanks!

Dave Edis - Senior Developer
interactivetools.com

By kovali - November 15, 2013

OK Dave thanks for your help.

I've deleted the CSS lines and now the error seems to be gone, but I still don't get a PDF page...

I think I'm having this problem with coding now:

The page I want to create as a PDF = http://www.vdwprojects.be/new/pandenDetail.php?LOT-3-80

My link to create the PDF ("Click to view as PDF"): <a href="?pdf=1"><img src="images/pdf.jpg" width="34" height="32"></a>

But then I get this URL as a result : http://www.vdwprojects.be/new/pandenDetail.php?pdf=1   ( without LOT-3-80 )

What am I doing wrong, or how should the link be coded to get the correct URL pls ??

Koen

By Dave - November 18, 2013

Hi kovali, 

You can use some code like this:

<a href="?pdf=1&<?php echo @$_SERVER['QUERY_STRING']; ?>">

To generate a link like this:

 http://www.vdwprojects.be/new/pandenDetail.php?pdf=1&LOT-3-80

But that still seems to just pause for a long time and then return HTML code when I type in that URL directly on your server.

When you go to the Create PDF Examples under the plugins menu here: /cmsAdmin/admin.php?_pluginName=createPDF&_pluginAction=examples

Do those examples work? 

Let me know, thanks!

Dave Edis - Senior Developer
interactivetools.com

By Dave - November 19, 2013

Hi Kovali, 

Can you try updating the examples to have ../../ instead of ../../../ (remove one of the ../).  That error is because the plugin is expecting itself to be in /plugins/createPDF/examples/.

Anyways, the approach I'd suggest is to get a simple page working and then work from there.  So if either the "Test Server Requirements" or the examples generate a PDF than you know PDF generation is working.

So for the next step I'd recommend creating a copy of pandenDetail.php such as pandenDetail_test.php and removing large blocks of the HTML code until you can find the HTML/CSS that is causing the PDF generation to fail.  PDFs can be a bit more picky then a regular web page about coding.

If you want a hand with it feel free to email me FTP login details to dave@interactivetools.com and I can take a look at that page (email, don't post login details to the forum).

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By kovali - November 19, 2013

Hi Dave, thx for the help.

The example is working now, after the update.

I' ve sent you the ftp settings by mail.

Koen

By Dave - November 20, 2013

Hi Koen, 

Ok, Here's a working test page: 
http://www.vdwprojects.be/new/pandenDetail-test.php?pdf=1&LOT-3-80

The line that was breaking it was this <script src="js/jquery-ui.js"></script>.  Something in that version of jquery-ui.js was causing the PDF generation to fail.  Either commenting out that line or loading a more recent jquery fixed the issue.  For the test page I just loaded the latest jquery from their site with these urls: 

<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

See if you can get it to work with that.  If not, create a simpler "printer page" type of page and create your PDF from that.

Also, sometimes Google Maps don't always display properly in generated PDFs.  There's a post here on how to load static map images from Google and I included that code in the test page:
http://www.interactivetools.com/forum/forum-posts.php?postNum=2215478#post2215478

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By kovali - November 20, 2013

Hi Dave, thanks for your great support.

Somehow the new jquery code is breaking up the design of my site :(   So I will have to find a different solution.

In your comment you said:  "If not, create a simpler "printer page" type of page and create your PDF from that."

I assume I can build a simpler page with less information and simpler css and create a PDF from that, but can you show me what the link should be in pandenDetail.php to print let's say pandenDetail-simple.php ?

Thanks again,

Koen