I believe you need to pass a filename and path to pdftotext. Your code just causes the program to run without any input data to convert. It should probably be something like:
I use pdftotext on a local server with this function
PHP Code:
function pdfTxt($path){ $o=shell_exec('pdftotext -enc UTF-8 '.$path.' pdf.txt'); $c=file_get_contents('pdf.txt'); // Some corrections depending on your pdfs return preg_replace("@\x0D\x0A\x0D\x0A\.\x0D\x0A\x0D\x0A\.\x0D\x0A\x0D\x0A[^\x0D]+\x0D\x0A\x0D\x0A[^\x0D]+\x0D\x0A\x0D\x0A[^\x0D]+\x0D\x0A\x0D\x0A@"," ",$c); }
pdftotext is in same directory as the running php file, $path is the pdf file relative path. Without pdf.txt the new txt file take the name of your file.
Download it on this page and read the pdftotext.txt file for other options...
Good luck !
I use pdftotext on a local server with this
pdftotext is in same directory as the running php file, $path is the pdf file relative path. Without pdf.txt the new txt file take the name of your file.
Download it on this page and read the pdftotext.txt file for other options...
Good luck !
I may misunderstand you. I already have on my local Linux machine pdftotext and it run from terminal. As I think it is belong to package called poppler.
Do you mean that xpdf is another package than poppler and it do its functionality?
It is better to talk to the organ-grinder than to his monkey !
I work on a local server with windows. I have fund pdftotext.exe in the package xpdfbin-win-3.03.zip with other files like pdftoppm.exe, pdfimages.exe, ... and her descriptions, options in pdftotext.txt, pdftoppm.txt, pdfimages.txt ...
I do not know poppler but read on this page that Poppler is a PDF rendering library based on the xpdf-3.0 code base.
Thank you for your valuable hint.
Now I able to see the error:
PHP Code:
/usr/bin/pdftotext: /opt/lampp/lib/libjpeg.so.62: no version information available (required by /usr/lib/libpoppler.so.13) /usr/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
I think it's something related to XAMPP for linux, If you know how to solve it, I will be appreciated.
I am not entirely sure what .so is, but I can tell you that the error is complaining about GCC missing- which is REALLY ODD considering you're running a program calld pdf2text and not compiling anything.
I would send the error to the system admin, it doesn't look like something you can fix without being root.
GCC is a `C` compiler
PHP is written in C also (it's a programming language).
Edit:
but first, make sure you can't run the actual program pdf2text from a real shell. Use putty if you're on windows, otherwise open a terminal and use ssh user@host.com or just man ssh and it will explain it.
Last edited by eval(BadCode); 12-05-2011 at 04:04 AM.
I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;
Have you tried running it as the Apache/www-data/php user (whichever your system has configured? It is possible that the user running the php doesn't have the same access as your user account.
Have you tried running it as the Apache/www-data/php user (whichever your system has configured? It is possible that the user running the php doesn't have the same access as your user account.
I think that the problem is not related to the access, the error message shows that it is about something missing. However, how could I know the user that running PHP?
I think that the problem is not related to the access, the error message shows that it is about something missing. However, how could I know the user that running PHP?
Is is possible that your user account has different classpath (or whatever it is called in your environment) than the account that runs PHP.
Bookmarks