Flash Air Native Extension: Direct Printing / Printing

  • Posted:
  • Proposals: 0
  • Remote
  • #701272
  • Expired
  • 0

Description

Experience Level: Intermediate
We have an existing Adobe Air POS Multitouch Application running on Windows.

We now need a printing functionality for our Adobe Air Android App, analog to the Air Printing Functionality revealed by the Air-Desktop-Profile.

It would be enough if the ANE is working with ONE specific Brand like Samsung Laser Printers or Epson Printers.

Ideally, this functionality would be extented to iOS, but Android has priority.


Here is our exisiting Printing-Code for Adobe Air Desktop Profile:

package com.nqxdev.piTouch.modules {

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.printing.PrintJob;

public class PrintNow extends Sprite {

private var pj:PrintJob;
public var supported:Boolean;

public function PrintNow() {
super();

pj = new PrintJob();
trace("PrintNow > printers:" + PrintJob.printers);

// Printer iteration/number is coming from the XML/CMS. printers.length will not work reliably, cause often the Windows XPS-Printer is installed by default. -> Printers.length>0 does NOT mean that there is an existing physical printer

// supported = PrintJob.isSupported || PrintJob.printers.length > 0;
supported = false;
}

// print array of bitmaps
public function print(sprites:Array, msg:String = "default"):void {
if ("default" == msg) {
msg = "Bitte haben Sie etwas Geduld.\nDie Seite" + (0 < sprites.length ? "n werden" : " wird" ) + " gedruckt...";
}

var sprite:Sprite,
printArea:Rectangle,
scale:Number,
bmp:Bitmap,
bmpd:BitmapData,
guiBmp:Bitmap;

if (pj.start2(null, false)) {

for (var i:int = 0; i<sprites.length; i++) {

bmp = sprites[i];
bmpd = new BitmapData(bmp.width, bmp.height, true, 0x000000);
bmpd.draw(bmp);
guiBmp = new Bitmap(bmpd);
sprite = new Sprite();
sprite.addChild(guiBmp);

// scale to fit page
scale = Math.min(pj.pageWidth/sprite.width, pj.pageHeight/sprite.height);
sprite.scaleX = sprite.scaleY = scale;
printArea = new Rectangle(0, 0, pj.pageWidth/scale, pj.pageHeight/scale);

try {
pj.addPage(sprite, printArea); // print sprite using calculated rectangle
}
catch(e:Error) {
// handle error
}
}

if ("" != msg)
PiTouch.Alert.flash(msg);

pj.send();
}
}

}
}


So we take a Sprite-Array as input, and via flash.printing.PrintJob, „pj.addPage(sprite, printArea)“ and „pj.send“ we communicate with the windows printer queue, efficiently printing silently without UI or Message Dialogues on the Windows-Standard-Printer.

We essentially look for a replacement for flash.printing.PrintJob as this Class is not available for the Air Mobile Profile.

We now would like to implement a similar functionality for Android, as we want to replace our Shuttle-POS-Systems with the much cheaper Android-Pcs.

Despite being cheaper, the performance is much better for the default-gpu-accelerated Air on Android as is for Air on Desktop…


So, maybe you have a good Solution for our problem, maybe there are more efficient ways then writing an ANE, for example using an android print server, but we have litte experience with mobile Systems so maybe you have a good Idea how to implement printing for our Multitouch-CMS-Software :-)


Thanks!

Stefan

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.