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 03:43:32 -0800 (PST)
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.)
All the best,
Keith
----- Original Message ----
Hi
I am reading text from Word docs without problems using the NSTextView method readRTFDFromFile.
Trying to read text from Pages documents with file extension .pages fail an returns empty strings. The same document saved in Word format works fine.
I was trying the NSString method stringWithContentsOfFile with various encodings but I get only garbage.
What is going wrong? I think it must be a simple way in Apple's Xcode to read Docs written with Apples Pages application.
Thanks for every response
Ruedi Heimlicher
_______________________________________________
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