automating iWorks/Pages

Discussion in 'Mac Programming' started by carleton, Jan 10, 2011.

  1. carleton macrumors member

    Joined:
    Dec 26, 2008
    #1
    My background: I have been and will continue to be a professional Windows C/C++/C# developer, so programming is nothing new to me. My question really revolves around where to go to learn how to automate iWorks/Pages:

    I have a task that requires pulling a bunch of images and their metadata out of a database (Firebird) and inserting it into a printed document. The rest of the document requires some real layout work that I would like to do with iWorks/Pages (InDesign is another canidate, but I think Pages will be easier). The inserting of all the images and metadata is very tedious and prone to error, so I would like to automate that by writing some code that gets the data from the database.

    Being new to the Mac (had it about a two weeks now) and very new to Mac development, haven't done anything more then install XCode. Where do I go to learn how to do this? Is it even possible?

    My impression is the only thing that can interact with Pages is going to be Applescript. If that is the case, is it possible to create objects in XCode that Applescript can use so I can create an object to deliver the data from the database to Pages?

    Sam
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Yes. There is a pretty good bridge from Objective-C/Cocoa into AppleScript. This also works with Objective-C++ which would allow you to write most of your code in C++ if you wanted.
     
  3. carleton thread starter macrumors member

    Joined:
    Dec 26, 2008
    #3
    That is GREAT to hear! I would REALLY appreciate it if you could provide me a link or two to Apple's documentation on how to do that, it would save me a lot of time figuring out how to navigate Apples online documentation. I also suspect it will help me understand how their documentation is laded out.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Erm, last (and only) time I tried to use the bridge (instead of the Objective-C classes to call AppleScript) it was, essentially, undocumented.

    Everything I know/found out is in this thread.
     
  5. carleton thread starter macrumors member

    Joined:
    Dec 26, 2008
    #5
    Thank you for the link it will be very helpful!

    Being a bit anti Apple, I must say: Thus what drives me batty about Apple:

    Great and wonderful user interface, but crappy support for developers.

    if one were to go look for documentation on how to automate MS Office from either .Net code or from the unmanaged code world, they will find tons and tons of info, and a LOT of it from Microsoft themselves.

    If Apple really wanted to become main stream, they need to start supporting developers. But I don't think they want to be main stream, so we live with the little crumbs they give us:)
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Further to the above the (very short) release notes for the bridge are still up (this was all I had to go on a year ago and still seems to be all there is now).

    AppleScript has it's own kind of built in discoverability: you should be able to open the Pages scripting dictionary using the Script Editor. I would happily admit that it is not always easy to piece together how stuff works from there.
     
  7. hhas macrumors regular

    Joined:
    Oct 15, 2007
    #7
    Alas, AppleScript is the eternal redheaded stepchild of Cupertino Lane. Says something when third-parties such as MS and Adobe do a much better job of supporting it than Apple themselves. See past rants ad infinitum.

    The total lack of official AppleScriptObjC documentation is particularly disappointing as it's actually a pretty decent product for a change. Fortunately, longtime AppleScript expert and all-round good egg Shane Stanley has written a book, 'AppleScriptObjC Explored', to address this hole:

    http://www.macosxautomation.com/applescript/apps/

    Haven't read it myself but have heard good things said about it.

    HTH
     

Share This Page