Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 26, 2013, 05:10 AM   #1
Jitin Jindal
macrumors newbie
 
Join Date: Feb 2013
Location: India
How to convert iwork document into pdf using objective c

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.....
Jitin Jindal is offline   0 Reply With Quote
Old Feb 26, 2013, 08:59 PM   #2
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
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?
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 27, 2013, 12:36 AM   #3
Jitin Jindal
Thread Starter
macrumors newbie
 
Join Date: Feb 2013
Location: 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 by Jitin Jindal; Feb 27, 2013 at 07:06 AM.
Jitin Jindal is offline   0 Reply With Quote
Old Feb 27, 2013, 07:03 AM   #4
Jitin Jindal
Thread Starter
macrumors newbie
 
Join Date: Feb 2013
Location: India
Quote:
Originally Posted by ArtOfWarfare View Post
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...
Jitin Jindal is offline   0 Reply With Quote
Old Feb 27, 2013, 07:21 AM   #5
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
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 by ArtOfWarfare; Feb 27, 2013 at 08:16 AM.
ArtOfWarfare is offline   0 Reply With Quote
Old Feb 27, 2013, 09:21 AM   #6
Jitin Jindal
Thread Starter
macrumors newbie
 
Join Date: Feb 2013
Location: India
Quote:
Originally Posted by ArtOfWarfare View Post
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 by Jitin Jindal; Feb 28, 2013 at 07:49 AM.
Jitin Jindal is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
PDF WordSmith - Convert PDF to Word kdan iPad Apps 0 Nov 29, 2013 03:29 AM
Document compatibility after latest iWork update? OrganMusic PowerPC Macs 2 Dec 16, 2012 12:32 PM
How is possible for a 2MB pdf document to be blank ? XPcentric Mac Basics and Help 7 Aug 23, 2012 12:52 AM
Distributing PDF document to iPads bizadvizor iPad 5 Aug 12, 2012 01:00 AM

Forum Jump

All times are GMT -5. The time now is 09:39 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC