BASIC

Author Topic: Airprint support - Possible ?  (Read 7429 times)

Offline Neurox

  • Mr. Polyvector
  • ***
  • Posts: 184
    • View Profile
    • http://www.borzini.it
Re: Airprint support - Possible ?
« Reply #15 on: 2011-Aug-02 »
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

Offline trucidare

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1377
  • Bachelor of Fail
    • View Profile
Re: Airprint support - Possible ?
« Reply #16 on: 2011-Aug-02 »
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

Offline Neurox

  • Mr. Polyvector
  • ***
  • Posts: 184
    • View Profile
    • http://www.borzini.it
Re: Airprint support - Possible ?
« Reply #17 on: 2011-Aug-02 »
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

Offline trucidare

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1377
  • Bachelor of Fail
    • View Profile
Re: Airprint support - Possible ?
« Reply #18 on: 2011-Aug-02 »
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

Offline Neurox

  • Mr. Polyvector
  • ***
  • Posts: 184
    • View Profile
    • http://www.borzini.it
Re: Airprint support - Possible ?
« Reply #19 on: 2011-Sep-25 »
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