Airprint support - Possible ?

Previous topic - Next topic

Neurox

Hi Trucidare,
I've tested your code but I received this error "expected identifier or '(' before string constant" for Extern "C" declarations.
My XCode version is 3.2.5
Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for screen printers | www.4pellicole.it

trucidare

you need to put the code in a .mm file because its objc++ sorry i forget this
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Neurox

Now compile, but nothing happens.
I added the NSLog into various points of code to see what happens :
Code (glbasic) Select

//
//  Airprint.mm
// 
//
//  Created by James on 21/07/11.
#import <UIKit/UIKit.h>

@interface AirPrintGLB : NSObject <UIPrintInteractionControllerDelegate>
@end

@implementation AirPrintGLB

- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
NSLog(@"Init code");
}
return self;
}


-(int) GLBAirPrint:(const char *) imagePath
{
   NSLog(@"Inside function");
NSString *path = [[NSString alloc ]initWithCString: imagePath];
NSData *myData = [NSData dataWithContentsOfFile: path];
   NSLog(@"Img: %@ ",path);

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if (![UIPrintInteractionController isPrintingAvailable])
{
NSLog(@"Sorry printing not supported!");
return -1;
}

if(pic && [UIPrintInteractionController canPrintData: myData] ) {
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [path lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
pic.printInfo = printInfo;
pic.showsPageRange = YES;
pic.printingItem = myData;

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Error accoured!");
} else {
NSLog(@"Tadaaaa");
}
};
[pic presentAnimated:YES completionHandler:completionHandler];

} else {
NSLog(@"Error with myData");
   return 0;
}
   NSLog(@"Out from function");
return 1;
}
@end

extern "C" int GLBAirPrint(const char* file);
extern "C" int GLBAirPrint(const char* file) {
AirPrintGLB *printInfo = [[AirPrintGLB alloc]init];
    return [printInfo GLBAirPrint:file];
}


This is result from debugger console :
Code (glbasic) Select

set cdir to: /var/mobile/Applications/3849DEC0-1EFA-4732-9BFE-710E0786C2B2/AirTest.app
exepath=curdir= /var/mobile/Applications/3849DEC0-1EFA-4732-9BFE-710E0786C2B2/AirTest.app
AudioStreamBasicDescription:  2 ch,  44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
Init Finalized
set cdir to: Media
2011-08-02 08:41:58.479 AirTest[773:6503] Init code
2011-08-02 08:41:58.483 AirTest[773:6503] Inside function
2011-08-02 08:41:58.490 AirTest[773:6503] Img: /var/mobile/Applications/3849DEC0-1EFA-4732-9BFE-710E0786C2B2/Documents/pollo.png
[Switching to thread 13315]
2011-08-02 08:41:58.653 AirTest[773:6503] Out from function

Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for screen printers | www.4pellicole.it

trucidare

cant say - on simulator it works fine, i tested with a gif file. i think i enable airprint via hack and test on real device
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Neurox

I'm crazy out.
I've made test and test and test
but the app don't print to my HP printer and not appear the window of configuration airprint  :rant:
Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for screen printers | www.4pellicole.it