PHP Script For PDF to HTML Conversion
- BAD Color Error: This error usually appear if the package doesn’t install properly.
- Execution Error: It is also a common error that php doesn’t execute the command and output file doesn’t generate. To solve this error you need to confirm few things.
- Confirm PHP is not running in the safe mode.
- You must execute the command as root. So you also need to set the Apache Security Settings.
$output=shell_exec(’/usr/bin/pdftotext ’ . $file_path);
$handle = fopen($file_name, "r");
$contents = fread($handle, filesize($file_name));
$file_count = strlen(str_replace(’ ’,’’,$contents));
- shell_exec function will not execute. If you don’t have permission to run ssh commands and also if your php is running in the safe mode.
- This script will generate a text file with same name and directory where you have placed the pdf file. So if the file isn’t create in that directory and your program will work you will able to track the file in the root directory. This means you have to correct your file path.
- Cannot count the calulation and upload the file. It is necessary to change the rights of processed folder to 777.