0 Replies Latest reply: Feb 19, 2013 1:47 AM by jitin Dev
jitin Dev Level 1 Level 1

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];


    PMPrinter thisPrinter= "printername";

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



          status= PMPrinterPrintWithFile(thisPrinter, printSetting, pageFormat,     

        (CFStringRef)MIMETYPE, fileURL);

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


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


          [printInfo release];

      return 0;

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


iMac, Mac OS X (10.5.8)