Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jitin Jindal

macrumors newbie
Original poster
Feb 18, 2013
13
0
India
hello
please help in solving an issue.
I want to print iwork document but they are not getting printed directly using objective c.
As i can print PDF files easily using objective c.
so i want to covert the iwork documents(pages,keynote,numbers) to PDF.
Is there any way of converting the documents into PDF??
like any API or somethiing else which will convert iwork document into PDF.

Thanks.....
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
If you look in an iWork file using an application like Zipeg, you'll see (I looked in a pages document, but I believe all the iWork documents look something like this)...

- QuickLook (a folder containing Preview.pdf and Thumbnail.jpg)
- buildVersionHistory.plist
- index.xml

It might be that simply extracting Quicklook/Preview.pdf might be all you want. If it's not, you'll have to figure out how index.xml is organized. I believe that index.xml contains everything that currently makes up the iWork document. I checked and everything that I typed in a one page Pages document was stored near the bottom of the index.xml file... I assume everything else pertains to formatting.

buildVersionHistory.plist doesn't contain much... it appears to somehow store the history of the document... IE changes that have been made overtime. I'm not quite sure how it works, as it seems to contain nothing but timestamps? Possibly the timestamps correlate to something in index.xml and index.xml actually stores all the changes you make in a document, as well as everything currently in the file?
 

Jitin Jindal

macrumors newbie
Original poster
Feb 18, 2013
13
0
India
Yes you are right that the quicklook contains the files .pdf and thumbnail.jpg but the quicklook contains the .pdf file only when we will check the "include preview in document" radio button in save menu of the document otherwise it will not create the .pdf file of the particular document.

And i just want to use some API of objective c that can do the conversion for iwork document into pdf file.

I am able to convert the ipage document using Applescript but for keynote and numbers i am not able to convert them so is there any way to do this thing.

Thanks...
 
Last edited:

Jitin Jindal

macrumors newbie
Original poster
Feb 18, 2013
13
0
India
If you look in an iWork file using an application like Zipeg, you'll see (I looked in a pages document, but I believe all the iWork documents look something like this)...

- QuickLook (a folder containing Preview.pdf and Thumbnail.jpg)
- buildVersionHistory.plist
- index.xml

It might be that simply extracting Quicklook/Preview.pdf might be all you want. If it's not, you'll have to figure out how index.xml is organized. I believe that index.xml contains everything that currently makes up the iWork document. I checked and everything that I typed in a one page Pages document was stored near the bottom of the index.xml file... I assume everything else pertains to formatting.

buildVersionHistory.plist doesn't contain much... it appears to somehow store the history of the document... IE changes that have been made overtime. I'm not quite sure how it works, as it seems to contain nothing but timestamps? Possibly the timestamps correlate to something in index.xml and index.xml actually stores all the changes you make in a document, as well as everything currently in the file?

Yes you are right that the quicklook contains the files .pdf and thumbnail.jpg but the quicklook contains the .pdf file only when we will check the "include preview in document" radio button in save menu of the document otherwise it will not create the .pdf file of the particular document.

And i just want to use some API of objective c that can do the conversion for iwork document into pdf file.

I am able to convert the ipage document using Applescript but for keynote and numbers i am not able to convert them so is there any way to do this thing.

Thanks...
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,560
6,059
You can use NSXMLParser to help you with parsing index.xml, but I don't think there's any API for automagically interpreting an iWork document for you.

Edit:

Wait, so your Applescript that converts Pages documents is adequate for you? Can you share the contents of that script? Also share your script attempting to do the equivalent with Keynote or Numbers...
 
Last edited:

Jitin Jindal

macrumors newbie
Original poster
Feb 18, 2013
13
0
India
You can use NSXMLParser to help you with parsing index.xml, but I don't think there's any API for automagically interpreting an iWork document for you.

Edit:

Wait, so your Applescript that converts Pages documents is adequate for you? Can you share the contents of that script? Also share your script attempting to do the equivalent with Keynote or Numbers...

ya sure its just few lines as below:

on run{}
tell application "pages"
set SourceFile to "filePathToPageDocumentWith .Pages Extension"
open sourceFile
set doc to front document
set destinationFile to "newFileToBeCreatedWith .PDF extension"
save doc in destinationFile
close doc
end tell
end run


Note: This is the script that I created to save the page document as pdf file as mentioned "destinationFile". i tried the same script for keynote and numbers but it is not working as "front document" is a keyword which is related with the pages document not with keynote and numbers.

If you find any way to convert the keynote and numbers to pdf then please let me know about it.

thanks....
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.