Wednesday, December 19, 2012

Move desktop items By a Script on Imac

This is a great example of when AppleScript is really useful for automating simple tasks like moving files around. In fact, you can do it with a script that is only three lines long.
Start by opening up AppleScript Editor, located in the Utilities folder inside the Applications folder. If you don't have Snow Leopard, the latest version of Mac OS X, this might be called Script Editor and instead is located in the AppleScript folder in the Applications folder. In the window that appears, paste the following three lines:
tell application "Finder"
   move items of (path to desktop folder) to folder (path to documents folder)
end tell
If you click Run, you should see all the items on your desktop move into your Documents folder. Choose Save As from the File menu, give the script a name like cleardesktop and change the File Format to Application. Save it somewhere safe where someone won't accidentally delete it. I have a folder inside my Documents folder called Scripts where I keep all my AppleScripts. Other people choose to store their scripts in the Scripts folder in the Library folder, because Apple has already put some ready made ones in there.
The next step is to make it run every time you shut down your Mac. This is pretty tricky to do, and involves using a lot of Terminal commands. Instead, a much easier way is to make the script run when you log in, which will essentially do the same thing. Just go to System Preferences, and click on the Accounts section. Choose your account from the list on the left, and then click on the Login Items tab. You can now either click the plus (+) button and locate your script, or just drag the script from a Finder window into the list.
Now, whenever you turn on your computer, all the clutter left over from the previous user will be automatically moved into the Documents folder.
The above script is just about as basic as you can get. Here’s an idea for a more complicated version. Instead of just dumping everything in your documents folder, it instead creates a folder in there with a name that includes todays date ( e.g. “Desktop 13/01/2010” ) and puts the items in this folder instead.
set foldername to ("Desktop " & short date string of (current date))
set docsfolder to (path to documents folder) as string

tell application "Finder"
   if not (exists folder (docsfolder & foldername)) then
       make new folder at docsfolder with properties {name:foldername}
   end if
    move items of (path to desktop folder) to folder (docsfolder & foldername)
end tell
Alternatively, the following script checks the file extension of all the files on the desktop, and sorts them into the Movies, Pictures, Applications and Documents folders depending on what they are. If you are feeling adventurous, you can modify the script to include your own folders and file extensions.
tell application "Finder"
   set desktopFolder to (path to desktop folder)
    set musicFolder to (path to music folder)
    set appsFolder to (path to applications folder)
    set picsFolder to (path to pictures folder)
    set moviesFolder to (path to movies folder)
    set docsfolder to (path to documents folder)

    set musicExt to {".mp3", ".aac"}
    set appsExt to {".dmg", ".sit", ".app"}
    set picsExt to {".jpg", ".gif", ".tif", ".png", ".psd"}
    set moviesExt to {".avi", ".mpg", ".mov", ".m4v"}
    set docsExt to {".pdf", ".txt", ".doc", ".xls", ".key", ".pages"}

    set allFiles to files of desktopFolder
    repeat with theFile in allFiles
       copy name of theFile as string to FileName

        repeat with ext in musicExt
           if FileName ends with ext then
               move theFile to musicFolder
           end if
       end repeat

        repeat with ext in appsExt
           if FileName ends with ext then
               move theFile to appsFolder
           end if
       end repeat

        repeat with ext in picsExt
           if FileName ends with ext then
               move theFile to picsFolder
           end if
       end repeat

        repeat with ext in docsExt
           if FileName ends with ext then
               move theFile to docsfolder
           end if
       end repeat

        repeat with ext in moviesExt
           if FileName ends with ext then
               move theFile to moviesFolder
           end if
       end repeat
   end repeat
end tell

Tuesday, July 31, 2012

How to create interactive PDF forms

If you’re like me then you like everything from your website down to your legal contracts to look well designed and function to your client’s liking — which in most cases is… easily!
The problem with creating forms and other documentation for a client to fill out is most are created in Microsoft Word, or other form of word processors, because we’re afraid the client won’t have the right software to open, add to it and return it.
In doing so, the design is compromised because of word processor’s inability to function like professional design software. While MS Word is typically found on most computers and regarded as the most compatible document to send someone to fill out and return, that doesn’t mean you can’t have your cake (aka “good design capabilities”) and eat it too (aka “compatibility).

Adobe Acrobat Professional to the rescue!

Adobe Acrobat Professional gives you the ability to turn your previously designed, standard PDF file into an interactive form that clients can download, easily fill out, print or effortlessly return to you by email. All they need is the free Adobe Acrobat Reader, which can be download here. And most clients I’ve spoke with already have it installed. Here’s how you can create your own interactive PDF:

Create your document

First, design your documentation or form in the software of your choice. InDesign is my first choice of page layout programs, but feel free pick your own…
Once you’re completely satisfied with the design, save it as a PDF.

Open it in Acrobat Pro

From the top toolbar, choose File > Create PDF > From File… Then, choose the PDF file you created above and click Open.
pdf open in acrobat
You should now see your beautifully designed PDF open in Acrobat Pro with a toolbar that looks similar to the highlighted image above. This toolbar is where you provide interactivity to your static PDF.

Adding Interactivity

Select the Text Field Tool (pictured below):

text tool
Drag out boxed areas on your PDF where you would like the client to add their information. NOTE: Acrobat can also use its auto-detection feature to assign text box areas to predetermined underlined areas.
text field area
After each box you create, a dialog box will appear that allows you to customize the text field area. Below you can see my changes, but feel free to customize to your liking.
general
appearance
options

Adding the ‘Submit’ Button

Now that you have your text areas specified, it’s time to add a ‘submit’ button so your clients can easily email you back the completed form.
For this we need to select the Combo Box tool (highlighted below):
combo box tool
Once again, drag out an area where you would like your ‘submit’ button to appear.
combo box area
Again, a dialog box will appear. While you can customize these settings as well, the steps (images) I have listed below are essential for making the form submittal by email.
actions
Once you click ‘Add…’ a new dialog box will appear. Change these settings to:
url for submittal
Click ‘Ok’ and continue making changes to the other tabs:
submit options
click to email
Click ‘Close’. You should now have text areas and a submit button that looks similar to this:
completed form

Last Step… Customize the Form Preferences

This step is not necessary but handy!
From the menu bar choose Acrobat > Preferences… (or Edit > Preferences on a PC). From here you are able to change the default yellow highlighted text areas (seen above) to better fit the look of your form.
customize form settings
That’s it! You now have a PDF document that can be edited by your clients and quickly emailed back to you.

Saturday, May 26, 2012

Installing PDFlib on Apache/PHP running on Windows:

I just successfully installed PDFlib on windows XP running WAMP. Here is the process:Installing PDFlib on Apache/PHP running on Windows:
Here is the direct download for the currently latest version for windows:
http://www.pdflib.com/binaries/PDFlib/701/PDFlib-7.0.1p1-MSWin32-php.zip
Once you have finished downloading, extract the zip file. 
In the folder "bind" choose your php version, and open that folder. (php4 or php5)
Inside that folder, you'll have PHP sub versions, choose your sub version. If you don't know the exact PHP version you'ure using, run a php page with <?php phpinfo(); ?> in it. The PHP version will be printed right at the top of the page.
Inside the sub version folder, you'll find the pdflib's .dll file for your php version.
Copy the .dll file and save the copy in your php extensions folder. This folder is defined in php.ini as "extension_dir". So if you don't know what it is on your machine, open php.ini and search for 'extension_dir'.
On my system is was: c://wamp/php/ext/
Now open php.ini and add the extension. The format for this is:
  1. extension=file.dll

where file is the file name of the extension.
eg:
  1. extension=libpdf_php.dll

Now you have to restart apache, and you should have pdflib installed. I tested this using:
  1. <?php
  2. if (class_exists('PDFlib')) {
  3. echo 'PDF Lib supported';
  4. } else {
  5. echo 'PDF Lib not supported';
  6. }
  7. ?>

I don't know about XAMP, you you might have the pdflib extension already added to your extensions directory. If so, then all you have to do is add the lineextension=libpdf_php.dll to php.ini

Thursday, May 24, 2012

Creating Image Maps in Dreamweaver CS5




Adding images to your site is one of the simplest and easiest ways of making your web content come to life. I’d say it’s almost mandatory, actually. After all, what better way to ensure your content resonates with your viewers than to provide visual aids and imagery? You can add further interactivity to your site, however, by making your images more than static visual aids, but a dynamic, multi-part navigation system that can link to other pages on your site. These types of images are called image maps.

What are image maps?

An image map allows a regular image to serve as a type of navigation system. We can use an actual map as a perfect example of this. For instance, when users click on certain locations–sometimes called hotspots--on the image, they can be taken to pages related to those locations.
For example, Southwest Airlines’ Route Map page displays a map of the United States. The cities that Southwest flies to are indicated with a small circle. When users click on a circle or city name, they are taken to a page about that city through the use of an image map.
Image Map Example

How to make an image map

You can make any image an image map by designating clickable areas on it and giving it a link or an action. To create an image map, insert an image (Insert –> Image) on a page and select it in Design View. The image map tools are available in the Properties Inspector as seen below:
Image Map Buttons
Clickable hotspots can be created in three shapes:
  • Rectangles
  • Circles
  • Polygons
Once a hotspot has been placed on an image, the link location must be completed. Each hotspot may link to a different page.
And that’s all there is to it!
Have you thought of any creative or brilliant image to make into image maps? A map of the world, perhaps, or even a photograph of people? Please share if you have!