Guest nishac Posted December 15, 2006 Share Posted December 15, 2006 I am a starter only.But my firm has assigned me a work.I have to read the contents of files ie.text and pdf files.From text files we can easily read.But from pdf we cannot.So a plugin called xpdf is available.In that pdftotext command converts pdf files to text and make it readable.What makes me wonder is that it worked perfectly offline.In my local host.But when am uploading it online the same code is not working.I changed the folder file permissions everything.But in vain.So i have regarding how to give the pdftotext path correctly which can convert my pdf file to text.Am herby attaching the code also.define('CONVERT_PATH', str_replace('\\', '/', dirname(__FILE__)));function convert_pdf2text($data, $path2xpdf = null){ if (!$path2xpdf) { return ''; } $tmpname = time(); umask(0755); $fp = @fopen(CONVERT_PATH.'/'.$tmpname.'.pdf', "w+"); if (!$fp) { return ''; } else { fwrite($fp, $data); fclose($fp); chmod(CONVERT_PATH.'/'.$tmpname.'.pdf', 0755); exec($path2xpdf.' '.CONVERT_PATH.'/'.$tmpname.'.pdf '.CONVERT_PATH.'/'.$tmpname.'.txt'); if (file_exists(CONVERT_PATH.'/'.$tmpname.'.txt')) { chmod(CONVERT_PATH.'/'.$tmpname.'.txt', 0755); $text = @file_get_contents(CONVERT_PATH.'/'.$tmpname.'.txt'); @unlink(CONVERT_PATH.'/'.$tmpname.'.pdf'); @unlink(CONVERT_PATH.'/'.$tmpname.'.txt'); clearstatcache(); return $text; } else { @unlink(CONVERT_PATH.'/'.$tmpname.'.pdf'); @unlink(CONVERT_PATH.'/'.$tmpname.'.txt'); clearstatcache(); return ''; } }}thanking u Link to comment https://forums.phpfreaks.com/topic/30724-pdftotext/ Share on other sites More sharing options...
trq Posted December 15, 2006 Share Posted December 15, 2006 Xpdf is a program, not a so called [i]plugin[/i]. Are you sure the server you are uploading to has the xpdf program installed? Link to comment https://forums.phpfreaks.com/topic/30724-pdftotext/#findComment-141593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.