Re: reading text rom Pages doc
Re: reading text rom Pages doc
- Subject: Re: reading text rom Pages doc
- From: Keith Blount <email@hidden>
- Date: Mon, 8 Mar 2010 09:03:20 -0800 (PST)
Hi,
I filed an enhancement request on this back in November 2007, #ID 5597713, asking for NSAttributedString additions that would read and write .pages files. (One of the most common questions I get from new users is why my app can import Microsoft formats but not Apple's own.)
Regarding my earlier suggestion that you could probably hack it through QuickLook, please disregard that. I looked at this again and found that broke with Pages '09, and it was an ugly hack anyway. The best way to achieve this currently is definitely by AppleScript, by batch converting any .pages files passed to the app to temporary RTF or RTFD files and then opening those instead. But obviously that requires telling the user that your app will open Pages, and that the user has Pages installed.
All the best,
Keith
________________________________
From: Charles Srstka <email@hidden>
To: Keith Blount <email@hidden>
Cc: email@hidden; email@hidden
Sent: Mon, March 8, 2010 4:35:50 PM
Subject: Re: reading text rom Pages doc
On Mar 8, 2010, at 5:43 AM, Keith Blount wrote:
Hi,
>
>As others have pointed out, there is no way to read .pages documents as the .pages format is proprietary and unpublished. Some of the specs were published here:
>
>http://developer.apple.com/mac/library/documentation/AppleApplications/Conceptual/iWork2-0_XML/Chapter02/02Pages.html
>
>But the Pages section hasn't been updated since 2005 and the .pages format has changed since then - and moreover the above makes it very clear that the XML scheme is unlikely to be published properly and that you shouldn't rely on it for writing your own importers.
>
>So the only way is to tell your users to export to RTF or Word format, or, as Paul suggests, try using AppleScript. There is one other possibility, but it's an ugly hack and could break if the Pages format changes. Depending on whether the user chooses "Include preview in document" or not, .pages files will either have a PDF file containing all their documents inside the QuickLook folder in the project package (recent .pages files are zip archives), or QuickLook will generate HTML to show the preview. So you could try extracting the PDF file from the .pages QuickLook folder and loading the text from that. If that doesn't work (because the user hasn't chosen "Include preview" for that document), you could (on 10.6) use QuickLook to load a preview and try to navigate down the view hierarchy to find the WebView and extract the HTML. But this is fragile and if Pages '10 changes the way the QuickLook preview is generated, it will break - and it will be
>different for past versions of the format too.
>
>(I get a lot of outraged e-mails from new users demanding to know why my text app doesn't support the .pages format, which is why I considered the above. But it's pretty nasty so I'm just resigned to telling them to export to RTF.)
I am somewhat surprised that Cocoa includes support for Microsoft’s competing file formats, but not Apple’s own. I’ve just filed a bug report on this - anyone else who also finds this odd should perhaps do the same. It certainly seems to be in Apple’s best interest for the Pages format to be more accessible, in order to make Pages more useful as a word processor.
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden