Just Beyond The Bridge

How To Compress PDFs As You Create Them On A Mac

Tuesday, April 21, 2009

Pigeon-holed in “Technology

If you’ve ever created a PDF using OSX you’ll know that it’s very simple. Macs come with out-of-the-box PDF support which means you don’t need a program like Adobe Acrobat Reader (or anything more heavyweight) to open or save your files as such.

However, you’ll also know that emailing the files it creates takes much longer than it should - the created files are massive in relative terms.

I’ve created one-page invoices using PDFs for a long time, and thankfully, due to this great little PDF compression plugin, they are crunched down to a sensible size from the outset. However, I recently switched to let Billings handle my invoicing and it uses the default OSX PDF creation tool to generate it’s PDFs - big files ahoy.

To give you an idea of the difference in file size between a compressed one page document - Billings chucks out a 1.4Mb file, whereas my compressed versions of the same documents are about 19Kb. Not ideal when you quickly want to output an invoice, attach and send it.

So how do you solve it? Well there are some nifty features in OSX that you may not be aware of (or at least not use), namely Folder Actions. Essentially folder actions allow you to run a script every time a file is placed in or removed from a folder on your Mac.

This creates a great little hook on which we can run a script to compress the files in a specific directory then move them to a ‘Compressed’ folder once done.

Step-by-Step: How to Do It

1. Download and Install Compression Plugin

Download and install the PDF compression plugin. It’s a Quartz filter workflow that uses well-chosen settings to reduce your file size down. You will also now benefit from the use of it everytime you encounter a save dialogue from now on.

2. Create an Automator Workflow

Automator is a free program bundled in every OS X Mac (have a look in your Applications folder). It allows you to run series of tasks automatically in a single process. You simply need to create a workflow consisting of:

  1. Get Specified Finder Items (once added to the workflow, click Add to select the directory which will contain files to be compressed.
  2. Get Folder Contents
  3. Apply Quartz Filter to PDF Documents (Select ‘Compress PDF’ from the drop-down - this will only appear if you have installed the plugin as above)
  4. Move Finder Items (change the location to a place where the final, compressed files will be automatically moved)

3. Test The Workflow

Place a test PDF in your ‘Compressor directory’ (specified in step 1 of the workflow) then run it. It should compress this PDF, then move it to the ‘Compressed directory’ you specified in step 4, leaving the ‘Compressor directory’ empty.

Once you’ve got that working, you can automate the process, so this executes every time a PDF is saved or moved into the folder. Click save, and Save as Application (as opposed to Save as Workflow, otherwise every time you run it, the Automator program will want to load up fully instead of run in the background).

4. Create A Script

You now need to create little AppleScript which can run this workflow application.

Go to /Libaray/Scripts/Folder Action Scripts/

Duplicate one of the existing scripts, and rename it to something sensible like PDF - compressor.script

Open it and paste the following. You must manually alter the path to your Automator application as appropriate.

The code below is wrapping because of my thin blog layout. Best idea is to copy and paste directly, or View Source of this page to determine where the line breaks actually are if you are not sure.


on adding folder items to this_folder after receiving added_items
try
tell me
do shell script “open -a /Users/Andy/Documents/My\\ Mac/Compress\\ PDFs.app”
end tell
end try
end adding folder items to

Note! All spaces in the path must be double backslashed as above. To test if your typing is correct, paste the bit between the quote marks (e.g. open -a /Users/Andy/Documents/My\\ Mac/Compress\\ PDFs.app) into Terminial and run. If it runs the Automator application you created, your script will work. If it doesn’t, check the path you have typed.

Save it and close the Script Editor.

5. Set It Up

Find your ‘Compressor directory’ (specified in step 1 of the workflow) and right-click on it. From the menu that appears, select More > Configure Folder Actions…

Tick the ‘Enable Folder Actions’ box, then press the Add icon (+) to add the ‘Compressor directory’ as a trigger folder. Select it, and make sure the ‘On’ tickbox it ticked.

Next, click the Add icon (+) for the right hand pane to add a script. You should be able to find and select the AppleScript you have just created (something like PDF - compressor.script).

6. Done!

Close the window and you’re done. Every time somebody pastes or saves into the ‘Compressor directory’, the folder action will kick in, launch the AppleScript and that in turn will execute the Automator compression tool and move the compressed version of the PDF into the ‘Compressed directory’. Sorted.

Of course, there is lots more scope with this. Automator means you don’t need to know much AppleScript to get this going, but you can really push the boundaries if you are willing to experiment. This setup suits me, but it’s likely you’ll need to experiment to get it to the way you need it.

Comments (2)

Wordpress: Moving From Development or Staging to Live

Friday, April 17, 2009

Pigeon-holed in “Web-Design

It’s been a long annoyance of mine that Wordpress insists on writing paths directly into the database, so when switching from staging or production to live you have to alter these paths.

However, if you also find this an irritation, a quick way to solve it is to define a couple of constants in the wp-config.php file. You simply define the url and home addresses as below, and as long as you are running a server that supports the server variable HTTP_HOST (e.g. Apache) the switch should be automatic and override the settings in the control panel.


// WordPress address on settings page
define(’WP_SITEURL’, $_SERVER[‘HTTP_HOST’]);
// Blog address on settings page
define(’WP_HOME’, $_SERVER[‘HTTP_HOST’]);

4

Wednesday, April 08, 2009

Pigeon-holed in “Technology

I once had an urge to write. It was probably born out of a frustration that (at the time) everything creative I was involved with either was being hand drawn and product shaped, or laid out using a computer.

It’s been exactly four years since I wrote my first post on this blog, and not much has changed except I’ve lost my almost insatiable desire to write. It’s not that I don’t have ideas and thoughts, but everything these days appears to be summed up in 140 characters and I rarely think of a topic that I want to elaborate on, at least in a written form at least.

I know this won’t last forever. Twitter will come and go like everything else on the web. When I think back over the past seven years I have actively used the internet and consider all those things I used to visit/were so important to me at on time or other: DeviantArt, amused.com, Rojo, Friends Reunited, My Yahoo!, my Angelfire and FreeYellow websites, BoltBlue, Facebook - you realise things can only last a finite (and apparently increasingly short) period of time.

I also know I will get back my desire to write again one day. I tend to get these bursts of energy which have to be captured in words, but I think since I started running the business as a full-time occupation, that energy has been channelled via other routes.

I really have thought long and hard about the future of this blog. I’m not sure I want it all to remain online, especially in it’s current form. Malarkey did something a few years ago which was to archive anything interesting for anyone who really wanted to find it, but otherwise stopped it being immediately obvious. That appeals more and more.

Realistically, I don’t have to do anything about this site. It’s not doing much harm to anyone, except to me. Every time I visit it, it looks so forlorn and badly kept that I feel bad I don’t make many contributions to it anymore. But then again, for the two years that it truly shone I was in a state of overdrive and made commitments to write near daily - no matter how poorly - so comparisons to ‘the good old days’ are simply unrealistic.

I suppose also that in a way I feel like we (the ‘interneteers’) have created a bit of a primordial swamp over the past few years. Our general creativity, outpourings, projects that never went anywhere, willingness to ditch one web-based product for another at a moments notice and slimy trail of media (videos, podcasts, blog entries) can now be viewed with some hindsight. We’ve really worked hard since we got our hands on the controls, however now behind us we’ve left a soup of semi-useful stuff and we’re finally venturing out a little from it’s murky waters. Well, perhaps we’re not even that advanced. Maybe we’re just developing fins or something. A lot of effort has gone into getting us to this point, including a significant number of my own hours that went into this chronicle that I’m now seriously considering wrapping up on.

I wonder what the value of all of this will be in years to come.

This is Just Beyond The Bridge

Something About Me

Called Andy, I am passionate about design, love to travel, and have a knack for all things digital. This is the full story…

April 2009
M T W T F S S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

More Stuff

Back Catalogue

  1. Jan ‘10
  2. Oct ‘09
  3. Sep ‘09
  4. Aug ‘09
  5. Jul ‘09
  6. Jun ‘09
  7. Apr ‘09
  8. Mar ‘09
  9. Feb ‘09
  10. Jan ‘09
  11. Dec ‘08
  12. Nov ‘08
  13. Oct ‘08
  14. Sep ‘08
  15. Aug ‘08
  16. Jul ‘08
  17. Jun ‘08
  18. May ‘08
  19. Apr ‘08
  20. Mar ‘08
  21. Feb ‘08
  22. Jan ‘08
  23. Dec ‘07
  24. Nov ‘07
  25. Oct ‘07
  26. Sep ‘07
  27. Aug ‘07
  28. Jul ‘07
  29. Jun ‘07
  30. May ‘07
  31. Apr ‘07
  32. Mar ‘07
  33. Feb ‘07
  34. Jan ‘07
  35. Dec ‘06
  36. Nov ‘06
  37. Oct ‘06
  38. Sep ‘06
  39. Aug ‘06
  40. Jul ‘06
  41. Jun ‘06
  42. May ‘06
  43. Apr ‘06
  44. Mar ‘06
  45. Feb ‘06
  46. Jan ‘06
  47. Dec ‘05
  48. Nov ‘05
  49. Oct ‘05
  50. Sep ‘05
  51. Aug ‘05
  52. Jul ‘05
  53. Jun ‘05
  54. May ‘05
  55. Apr ‘05
  56. All Archives

Search