Posts Tagged ‘ PHP ’

PDF to Text + PHP

I have had a little project at work. The task is to convert a .pdf file into plain text, and then cut some parts out of the text to use them in my database. Well, the hardest part of it all was that I had to use PHP to do it. I had been looking for a conversion tool, but never really found anything. FPDI did not do what I needed, so I came across xpdf. I had to use “exec()” function of PHP to perform the conversion, but the output turned out to be very messy. So after some manipulations with the text I managed to convert almost all breaks. How much time I am going to spend on trying to “preg_match” the whole text for the stuff I need, I don’t know. I am sure it is not going to be easy, since it is not even HTML with all its tags and stuff. The thing is the conversion output format strictly depends on how the document was formatted in pdf. Well, according to my .pdf file, the creator was way far from publishing. Oh yeah, the tool is called pdftotext and is a Windows executable. However the package is distributed under many operating systems, so everybody can find a suitable package.

cURL behind proxy and all the heavy stuff…

Had to find a way to get webpages through proxy, and cURL for PHP was very helpful. Soon I am going to post a script with a possibility to use a proxy or not. Such a learning tip from me for people that might look for the same thing. I also decided to use Smarty and MDB2 with its MySQL driver for my new website automated monitoring system primarily because the script itself was too small to show to anybody :D Even though everything works well, I did not even realize that I would need a normal design for it, which I have no idea where to get. Anyways, cURL proxy usage example soon.

XAMPP – a fast way to create a local web-server

If you do not want to compile Apache, PHP, MySQL and other stuff, there is a very easy way to get the whole web-server thing going. First thing you have to do is download XAMPP from here for your favourite OS (Linux, Windows, Solaris, Mac OS X). Then simply follow the installation instructions on the website (It is really simpler than anything, for all you have to do is extract the archive). Finally, you will have a webserver with Apache, PHP, MySQL, FTP-server, an accelerator, and everything that might be enabled. It also has a web-configuration tool that allows you to set passwords for everything through your favourite browser. Amazing package for home networks and local webservers.

Programming style

Having worked with PHP for about 5 years, I have finally realized that there are so many different styles of programming. I mean, every developer has his own or ripped off somebody style. The most popular scripts have always seemed to diffcult for me, and may be I am just not qualified enough, but now I am starting to confuse myself with what I actually want to do. I am practicing OP, but I guess if you use it everywhere, your performance will fall down like an apple from a tree. So I decided that I have to find a compromise between OP and regular programming style. Right now I am focused on simplicity and performance, so I don’t want it to be to complex from the very beginning. I am planning to put only the most basic functions into my project. There will definitely be a plug-in system, authorization, default database and a simple template engine. I am writing everything myself, because I do not want to use these heavyweight third-party classes. The plug-in system will allow everybody extend the core without actually getting into the core code. Hope everything works out well.