Printing iwork documents like ipages,keynote,numbers file using cocoa console application

Please help in order to resolve the printing issue that i am facing while coding in objective c.

I want to print any file like (*.pages,*.numbers,*.keynote)

but i am not able to print these files using PMPrinterPrintWithFile function of objective c

I am able to print other files like *.txt,*.jpeg,*.png, *.pdf.



when I try to print iwork document like *.pages file with PMPrinterPRintWithFile, it returns a status as 1028

when I am printing other files like *.pdf,*.txt it is printed easily with status 0



and one more point I am not able to find out the MimeType of files like *.pages,*.number,*.keynote

the MIMETYPE object gets NULL value when i fetch it using the below code.

The Code I am using :



#import "Cocoa/Cocoa.h"



int main(int argc, char *argv[])

{



NSPrintInfo *printInfo = [[NSPrintInfo alloc] init];

PMPrintSession myPrintSession= (PMPrintSession)[printInfo PMPrintSession];

PMPrintSettings printSetting= (PMPrintSettings)[printInfo PMPrintSettings];

PMPageFormat pageFormat=(PMPageFormat)[printInfo PMPageFormat];

OSStatus err = PMCreateSession(&myPrintSession);

OSStatus status;

CFURLRef fileURL =(CFURLRef) [NSURL fileURLWithPath:@"filename example *.*"];

NSString* filePath=@"filename ex *.*";

NSString* FullPath=[filePath stringByExpandingTildeInPath];

NSURL * url= [NSURL fileURLWithPath:FullPath];

NSURLRequest* fileUrlRequest = [[NSURLRequest alloc] initWithURL:url];

NSError* error = nil;

NSURLResponse* response = nil;

NSData* fileData = [NSURLConnection sendSynchronousRequest:fileUrlRequest

returningResponse:&response error:&error];

NSString * MIMETYPE= [response MIMEType];

[fileUrlRequest release];

NSLog(@"MIMETYPE %@",MIMETYPE);

PMPrinter thisPrinter= "printername";

status = PMPrinterGetMimeTypes(thisPrinter, printSetting,&mimeTypes);

if(status==noErr)

{

status= PMPrinterPrintWithFile(thisPrinter, printSetting, pageFormat,

(CFStringRef)MIMETYPE, fileURL);

NSLog(@" value :%@",MIMETYPE);

NSLog(@"%i",status);

NSLog(@"=======Printer %@=======", PMPrinterGetName( thisPrinter) );

}

[printInfo release];

return 0;

return NSApplicationMain(argc, (const char **) argv);

}

iMac, Mac OS X (10.5.8)

Posted on Feb 19, 2013 1:42 AM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Printing iwork documents like ipages,keynote,numbers file using cocoa console application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.