Linux-based MS Office thumbnail generation - php

I've been taken onboard to work on a PHP-based web application. One part of the application generates thumbnail images for MS Office documents on demand, and it uses MS Office + the VeryPDF docprint utility to do this. Because of this one requirement, the system is running on Windows Server 2003 + IIS.
I would prefer to have the system running on a Linux server, rather than MS, as I have far more experience in administering Linux systems than Windows and we have no other in-house technical staff.
Does anyone know a way to handle the document conversion using native Linux software? I would love something PHP native, but am willing to look outside that if necessary.

I have never done anything like this, so I'm just throwing an idea off the top of my head.
Have you thought about utilizing Open Office's capabilities to create thumbnail images? I know OO saves thumbnail images within a created document, so all you need to do is extract the image to display it. (This is demonstrated on the Ubuntu forums.) You could always do something sort of "hackish" where you use run a file through OpenOffice and extract the image to display a small thumbnail.
Again, I have no idea how well this will work, but it may be worth a shot.

To anyone else who comes across this, I have ended up going with the newer version of jodconverter. The sample code includes a basic web page that can be POSTed to using something like Pear's HTTP_Request2. A sample class (by yours truly) which uses this is mentioned in the comments in jodconverter's group on google code.

Related

Javascript/Html5 Project - some questions

I am thinking of getting into JS/Html5 to do some web applications.
At the moment I am using Visual Studio Express 2010 (I am coming from a c#/silverlight/mssql background). Its nice. However, if I am doing html5/js I would prefer to write server side database lookup scripts in php for mysql, rather than mssql. VS does not cater for php mysql (as far as I know).
What ide is best for this? Do I need to install wamp server or somthing like that? (It needs to be free, this is just a hobby.)
Also, for non-database applications, eg simple games, how could I make my js/html5 app into as close as a downloadable app as possible? Is it possible? Downloading and unzipping a zip file is fine, if that has to be done.
The last thing I might need to know is how to save a text file to the hard drive. I think it can be done using Internet Explorer, but could you create a html page on the fly, with a copy button, which you could then instruct the user to paste into notepad, or somthing like that?
For IDEs, NetBeans is nice and simple, and works well for web stuff. You don't really need an IDE though. It won't be as helpful as it is in .NET. Plenty of web developers use simpler text editors. If you have a Mac I like TextMate.
If you need to serve files from a web server you will need a web server, but for most things you can develop just via the file system and file:// urls. You will run into problems if you're trying to do AJAX - see jQuery Ajax request from local filesystem (Windows file:///)
Downloadable apps can be pretty much implemented with the HTML5 Offline Application spec. See http://www.w3.org/TR/html5/offline.html for the formal stuff, but there are lots of examples, e.g. http://www.html5rocks.com/en/tutorials/appcache/beginner/.
As far as saving a text file, for security reasons I don't think that regular cross-platform JavaScript will let you do this. It's easy to do if you have a web server and you're serving up files and services for AJAX calls though.

Convert PHP-MySQL web application to desktop app (exe)

I have developed a PHP-MySQL web application, which is a school-based project.
My client wants this application to be converted into a .exe file such that it can be installed on his desktop and use it.
How the PHP website can be converted to a .exe file and can it be run without the need of a database/server software?
Please advice.
The convenient solution is not to convert the website to .exe. I think it will be better if you have portable server/php/mysql and make the website work from a usb or CD with autorun.
NuSphere's PhpDock claims to do this: It serves as a deployment helper and comes with a bundled web server. However, I don't know about the database part, and it's not free.
PhpDock enables you to deploy any PHP web application as a Stand Alone Windows Desktop application w/o any changes in the code.
I don't know that particular product, but I have been using their IDE for years and am quite happy.
try using a site-specific browser. it will make a desktop app that is basically a portal running to your webapp. try this one:
https://mozillalabs.com/prism/
It allows alot of advanced features like system tray icons and such. I have used it many times!
Hope this helps, JL
Short answer: Not possible.
Long answer: It depends.
You could install a web- and database server on his machine (or create an installer that does it) and run the application locally on his machine.
or
You keep the application on a server and just provide a launcher that opens his browser and points it to the URL of the application.
As Artefacto mentioned, it might be a good idea to switch to SQLite instead of MySQL but depending on how your application is written it might require a lot of code and SQL Query changes.
No. You have at least to remove the dependency on MySQL (and use e.g. sqlite instead).
Then, you would either have to:
Convert the webpages to windows dialogs. This would completely change your application (e.g. what would originally be http "form submissions" would be someting completely different). At this point, it'd much easier to write a .NET application
Bundle a web server (e.g. Apache) with PHP installed.
Another try would be to turn your php project into PHP-GTK (http://gtk.php.net/).
Yet another one is to give HPHP a try (https://github.com/facebook/hiphop-php/wiki/) and try to turn the generated C code into something like a .DLL in .NET and use it for the logic while coding the UI in say, C#.
Just create a simple program in C or C++ that will just add icon in Start menu, desktop and Quickstart. If your client clicks the icon it will open the default OS browser and point it to URI of your application online.
That might fool your client :)
Or maybe it will be enough for him (he might be asking you to convert it to exe because he can't remember URI or something - ask him what is the reason).
You can use xampp open-source project to pack your PHP site into an executable file.
Use the following steps:-
1. Download Xampp source code.
Add your PHP file inside htdocs directory(Ref:- https://sourceforge.net/p/xampp/code/HEAD/tree/win32/xampp/htdocs/).
Now compile the XAMPP source code and distribute it.
For DATABASE creation and initial data loading in the database, you can code your site in such way that if database is not created, it redirects the page to install.php which do the database creation and data loading task using sql file provided(you need to add SQL file containing database structure and required data).
Don't forget to delete the SQL file post installation of database.
Not sure that's gonna be possible but have a look at:
WinBinder
WinBinder is a new open source
extension for PHP, the script
programming language. It allows PHP
programmers to easily build native
Windows applications.
(source: winbinder.org)
Solution 1:
There are several solutions to convert your web application into a desktop application, the one I prefer is the open source solution: PhpDesktop, but unfortunately it only supports SQLite.
Best Solution:
To convert your PHP application with MySQL I know a paid solution that does this: 'ExeOutPut For Desktop', it is the best for this job
Php desktop is the way to go, it's actually very simple to modify to the version of PHP you want to use and is open source too https://github.com/cztomczak/phpdesktop

Generate an image / thumbnail of a webpage using X/Gui-less linux

There exists numerous solutions on generating a thumbnail or an image preview of a webpage. Some of these solutions are webs-based like websnapshots, windows libraries such as PHP's imagegrabscreen (only works on windows), and KDE's wkhtml. Many more do exist.
However, I'm looking for a GUI-less solution. Something I can create an API around and link it to php or python.
I'm comfortable with python, php, C, and shell. This is a personal project, so I'm not interested in commercial applications as I'm aware of their existence.
Any ideas?
You can run a web browser or web control within Xvfb, and use something like import to capture it.
I'll never get back the time I wasted on wkhtml and Xvfb, along with the joy of embedding a monolithic binary from google onto my system. You can save yourself a lot of time and headache by abandoning wkhtml2whatever completely and installing phantom.js. Once I did that, I had five lines of shell code and beautiful images in no time.
I had a single problem - using ww instead of www in a url caused the process to fail without meaningful error messages. Eventually I saw the dns lookup problem, and my faith was restored.
But seriously, every other avenue of thumbnailing seemed to be out of date and/or buggy.
phantom.js = it changed my life.

What do sites like Google Docs and Zoho Writer use to generate MS Office documents

I realise this may just be speculation, but I'd appreciate comments from anyone who has some insight into this.
Something like MS Word COM add-in, or an OO bridge, or a custom implementation.
The reason I want to know is that I want to provide basic online document editing (really basic, basically just rich text at this point) for a php web app. I'm guess I will store the markup in html format then convert to rtf/doc etc for user convenience.
The Apache POI project (written in Java) offers an interface to many file types from the MS Office suite.
You can run the Java code from within PHP using the PHP/Java bridge.
I used this once for an application where MS Word documents had to be indexed in a web application. I remember that setting everything up was quite a hassle, but then it worked very well and reasonably fast. (Unfortunately, the code was written in PHP4 and I don't own it, so I cannot help you out with any snippets here.)
P.S. I cannot post links since I'm a new user, so google for "Apache POI" and "PHP/Java bridge" to get to the respective project's homepage.
This class might help you. I've never used it but here are some links:
Reading from a Word Document with COM in PHP
create a word document
Create Word Document using PHP in Linux
They have probably written their own, maybe starting from wvWare or something similar. I have noticed that Google Desktop on Linux seems to use wvWare to parse MS Word documents.
The documentation for the Word file formats is available, but reading through it makes you realize that it would not be an easy task.
Automating Word or OpenOffice would be the easiest, but there might be licensing issues with using Word like that, and possible concurrency issues with using either of them on a web server.
A popular way to do it is to generate RTF with the file extension .doc. It works fine with Word and other editors, and users remain happy that it is "a DOC file"

Web Page Screenshots with PHP?

I know there is not a direct way to take a screen shot of a web page with PHP. What would be the most straightforward way to accomplish this? Are there any command line tools that could do this that I might be able to execute from a PHP script (I'm thinking something that would run in a 'NIX OS (OS X and/or Linux in particular)?
Edit: Or maybe some sort of web service I could access via SOAP or REST or ...
Edit #2: I found a related question discussing the CLI option, but I'd still be open to other methods if anyone knows of anything.
See webkit2png for an OSX commandline program that does this.
The page also mentions Linux alternatives.
[edit]: wkhtml2image is the newest kid in town, and it works better then anything else i've ever used.
[edit2]: As of 2014, PhantomJS seems to be the way to go, as it has the newest webkit version of the alternatives I know about.
[edit3]: In 2019, Puppeteer is the way to go. Official headless chrome, always up to date.
You can use the GD functions imagegrabscreen() or imagegrabwindow() to take a screenshot, but they're only available on Windows at the moment.
http://www.thumbshots.org/
html2ps does a decent job for relatively simple pages, and it requires very little in terms of external binaries, meaning it's very easy to install/use. If you control the pages you'll be capturing, then you can ensure that they'll render appropriately in html2ps. If you're hoping to capture arbitrary URLs, however, I'm not sure that the PHP port of HTML2PS is up to the task. It's also not the fastest thing in the world (expect render times in the seconds for complex pages), but that doesn't really matter for some applications.
Not sure if this would be enough for you, because it has some added stuff there, but would be worth giving it a try: http://www.snap.com
It's possible to get a base64 encoded image of a site by using the Google pagespeed api.
You can specify desktop or mobile views, but you are limited to an image of a certain size.

Categories