views:

210

answers:

2

I am working on a process to allow people to upload PDF files and manage the document (page order) via a web based interface.

The pages of the PDF file need to be cropped to a particular size for printing and currently we run them through a Photoshop action that takes care of this.

What I want to do is upload the PDF files to a dedicated server for performing the desired process (photoshop action, convert, send images back to web server).

What are some good ways to perform the functions, but sending updates to the webserver to allow for process tracking/progress bars to keep the user informed on how long their files are taking to process.

Additionally what are some good techniques for queueing/tracking jobs/processes in general (with an emphasis on web based technologies)?

+1  A: 

Derek, I'm sure you have your reasons for using Photoshop, but seriously, did Imagemagick render insufficient for you? I worked once with fax utility that converted Fax.g3 files to TIFF, then increased contrast and brightnes by 15% using Imagemagick and converted it back to PDF. IM worked as standalone Linux program invoked by system() call and I know there is new Imagemagick PECL extension.

Michał Rudnicki
+1  A: 

Create a queue, and push jobs to that. Have a cronjob or daemon running that takes jobs from the queue and process them. Make sure that you use some sort of locking, so you can safely stop/start the daemon/job.

If you expect the job to finish quickly, you can use a technique known as "comet". Basically, you establish a connection from javascript (Using XmlHttpRequest) to your server-side script. In this script, you check if the job is completed. If not, you sleep for a second or two - then check again. You keep doing this until the job finishes. Then you give a response back. The result is that the request will take a while to complete, but will return immediately. You can then take appropriate action in javascript (Reload the page or whatever).

troelskn