Showing posts from January, 2017

Steps to install wkhtmltopdf in Centos 7 Redhat

Steps to install wkhtmltopdf in Centos 7 Redhat
As you may know, wkhtmltopdf is a tool that is used to create a pdf on the fly from the Linux/Unix shell from any html document
Step 1 is to create a html document
Step 2 is to call wkhtmltopdf with the html document as input and pdf as output

But, before that, we need to install wkhtmltopdf in the Linux server machine.

Install wkhtmltopdf in Centos 7

Before we install wkhtmltopdf, we need to install the dependencies or support packages, which are required for wkhtmltopdf to work as expected.

So, we execute the following steps.

i. sudo yum install -y xorg-x11-fonts-75dpi
ii. sudo yum install -y xorg-x11-fonts-Type1

Let us get the rpm package from the link using the link below.

sudo rpm -Uvh wkhtmltox-

error: Failed dependencies:
        libXext is needed by wkhtmltox-1:
        libXrender is needed b…

Call to undefined function mcrypt_encrypt() in ... on line ...

Call to undefined function mcrypt_encrypt() in ... on line ...
When porting from my local server to the live server for testing, the php page was not loading and returned an Error 500 or Internal Server Error.

Analyse Apache error logs
As a first step, we tried to analyse the apache error logs to shortlist the reasons. The following line seemed to hold the key to the problem.

PHP Fatal error:  Call to undefined function mcrypt_encrypt() in /path/to/myAppFolder/myFile.php on line 13

Identify the problem
Missing php-mcrypt module
The issue seems to be related to a missing module in the Centos server. The php program was using the php-mcrypt module and it was not yet installed on the server yet.

Install php-mcrypt and restart Apache
So, we installed the php-mcrypt module using the below command

sudo yum install php-mcrypt

As a final step, we restarted the Apache Web Server

sudo systemctl restart httpd

Calling the php program now does not generate error now. Problem of Call to undefined function mcryp…

Ajax call not working as expected in Firefox

Ajax call not working as expected in FirefoxOkay, I had this peculiar problem of my web form updating the relevant tables when being called from Google Chrome and not doing so, when the call was made through Firefox.

The form went into sleep and did not respond after the Submit button was clicked. It looked as if the Ajax call was in indefinite loop in Mozilla Firefox.

As we went digging for reasons that this was happening, we realised that Firefox is strict about how data has to be sent to it.

Google Chrome is someone who tries to make sense out of the data and so, we got away with Chrome.

So, we understand that what we need to return from a php, which is being called through an ajax request, is content preceded by a header, which indicates the type of content that follows.

It could be any of these types as defined below.

Header Content-type: Common examples:
text/plain image/png