in reply to Running an external GUI program

Thanks for all the great ideas.

As far as compression goes, I can't use bzip, gzip, etc. because the PDFs need to be viewable on the web. There are no command line switches that I have been able to find unfortunately, so that's out.

I'm not sure how to check the file lock, as has been suggested, but I will look in to that. Since OSX is built on a BSD kernel, it should be pretty straight forward to do.

The AppleScript option seems to be a rather promising alternative to calling the app from the command line.

I'll have to let you know what the results are.

Replies are listed 'Best First'.
Re^2: Running an external GUI program
by MidLifeXis (Monsignor) on Feb 01, 2007 at 22:47 UTC

    The compression used by gzip is compatable with one of the compression encodings on the web. Unless you are talking about optimizing the PDF for web use, which is an entirely different can-o-worms.

    --MidLifeXis

Re^2: Running an external GUI program
by jsegal (Friar) on Feb 02, 2007 at 09:34 UTC
    What compression tool are you using?

    Even if that tool doesn't have a batch/command-line way to run it, there are probably other equivalent tools out there. For example, you might look at http://multivalent.sourceforge.net/Tools/pdf/Compress.html It is admittedly not in perl (it is in the other popular four-letter cross-platform language), but it is a free tool that shrinks PDF files but keeps them as PDF format (i.e. it does the compression internal to the PDF format so they are directly readable by PDF viewers). It is command-line based. There is a perl script up on http://wiki.scribus.net/index.php/Web_optimised_PDF that uses the ghostscript library to create smaller PDF files -- that particular script is from a package called "Scribus", but it could serve as a starting point).

    Best of luck.



    --JAS
      Another tool to consider: pdftk

      From the blurb ...

      If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a command-line tool for doing everyday things with PDF documents. Keep one in the top drawer of your desktop and use it to:

      * Merge PDF Documents
      * Split PDF Pages into a New Document
      * Decrypt Input as Necessary (Password Required)
      * Encrypt Output as Desired
      * Fill PDF Forms with FDF Data and/or Flatten Forms
      * Apply a Background Watermark
      * Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels
      * Update PDF Metadata
      * Attach Files to PDF Pages or the PDF Document
      * Unpack PDF Attachments
      * Burst a PDF Document into Single Pages
      * Uncompress and Re-Compress Page Streams
      * Repair Corrupted PDF (Where Possible)

      Pdftk allows you to manipulate PDF easily and freely. It does not require Acrobat, and it runs on Windows, Linux, Mac OS X, FreeBSD and Solaris.

      Pdftk is free software (GPL).