CGI scripts are usually run as a different user (www-data etc.) HTML::HTMLDoc uses an external programme, htmldoc. Are you sure this user has permissions to run it? What do the logfiles say?
Thanks for your reply.
I guess the user has permission to run the program because the file was set to 777 mode and the program able to generate the pdf with 0 bytes. I forgot to mention in my last post that the program generated pdf,and, the problem is it did not write the pdf content.