web_dvlp_sd
web_dvlp_sd

Reputation: 177

How to install and use wkhtmltopdf?

After a bit of researching/googling, I'm sold that wkhtmltopdf is the best way to export our website to PDF's. The website is actually a web application that users log in to and has a combination of HTML/Javascript and HTML.

I have looked at their google project page but could not find a user-friendly way that explains how to initiate this whole process, either through the HTML header or the Javascript somewhere?

I downloaded the .exe and .lib files, do I need to upload them to the server and reference them somewhere? I would like to be able to add a button on each page to allow the users to download the complete page as a PDF.

Any help appreciated! Thanks..

Upvotes: 2

Views: 2542

Answers (2)

lubosdz
lubosdz

Reputation: 4500

Installation on CentOS 7 - latest version:

yum --enablerepo=epel-testing install wkhtmltopdf

The default epel repository has significantly older version.

Upvotes: 0

ppant
ppant

Reputation: 762

I think creating pdf on fly is a good choice but it all depends on the way you handle the web pages in your side. If there are static content then you can run the process in batch and can store the pdf in file system for all future references.

As you already have a button on your page so by using javascript you can write current content of user data to a file and then pass the file to server side code, the file should be used as input for wkhtmltopdf. On server side you will have to start wkhtmltopdf depends on language you are using you will have to execute and store the output.

(e.g.; in Perl you can use something like

system("/usr/bin/wkhtmltopdf-i386 TestPrint.html TestPrint.pdf");

On success you can directly output the pdf output to current user stream. WKHTMLTOPDF need to be installed on server side.

Upvotes: 1

Related Questions