There is a rich scripting model for Microsoft Office, but not so with Apple iWork, and specifically the word processor Pages. While there are some AppleScript hooks, it looks like the best approach is to manipulate the underlying XML data.
This turns out to be pretty ugly because (for example) page breaks are stored in XML. So for example, you have something like:
... we hold these truths to be self evident, that </page> <page>all men are created equal, and are ...
So if you want to add or remove text, you have to move the start/end tags around based on the size of the text on the page. This is pretty impossible without computing the number of words a page can hold, which seems wildly inelegant.
Anybody have any thoughts on this?
I'd suggest that modifying the underlying XML file is "considered harmful". Especially if you haven't checked to see if the document is open!
I've had a quick look at the Scripting Dictionary for Pages, and it seems pretty comprehensive; here is part of one entry:
document n [inh. document > item; see also Standard Suite] : A Pages document.
contains captured pages, character styles, charts, graphics, images, lines, list styles, pages, paragraph styles, sections, shapes, tables, text boxes.
body text (text) : The main text flow of the document.
bottom margin (real) : The bottom margin of the publication.
facing pages (boolean) : Whether or not the view is set to facing pages.
footer margin (real) : The footer margin of the publication.
header margin (real) : The header margin of the publication.
id (integer, r/o) : The unique identifier of the document.
So, I guess I'd want to know what it is that you want to do that you can't do with AppleScript?
Answer author Matthew-schinckel
Tickanswer.com is providing the only single recommended solution of the question Mac iWork/Pages Automation under the categories i.e xml , automation , applescript , iwork , . Our team of experts filter the best solution for you.