IPAD must-haves. And fun-to-haves.

Brighten your iPad with a colorful cover, stream to your TV, download pictures from your digital camera, and more. There’s already so much you can do with iPad and iPad mini

Apple Wireless Keyboard

The incredibly thin Apple Wireless Keyboard uses Bluetooth technology, which makes it compatible with iPad

Apple unveils iPad mini: ‘Thin as a pencil, light as paper’

iPad inspires creativity and hands-on learning with features you won’t find in any other educational tool

Lightning connector and FaceTime HD camera

Apple announces 4th generation iPad packing an A6X CPU

Pages

Showing posts with label iwork. Show all posts
Showing posts with label iwork. Show all posts

Thursday, February 21, 2013

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

    }


View the original article here

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

    }


View the original article here