0
votes

I want to print an image from a webcam without showing a printer dialogue and the image should fit the page. (Using AIR and Flex)

There are two options: use FlexPrintJob

var printjob:FlexPrintJob = new FlexPrintJob();
printjob.start();
printjob.addObject(image as IUIComponent,FlexPrintJobScaleType.SHOW_ALL);
printjob.send();

But: this will show the printer dialogue.

use PrintJob

var printjob:PrintJob = new PrintJob();
printjob.start2();
printjob.addPage(imageSprite);
printjob.send();

But: this won't scale the image to fit the page.

Any ideas how to achieve both?

Currently I think it's only possible to use the PrintJob and scale the image to fit the page by myself.

1

1 Answers

0
votes

I hope this helps.

var printjob:PrintJob = new PrintJob();
if(printjob.start()){
  var scale:Number;
  myScale=Math.min(printjob.pageWidth/imageSprite.width,printjob.pageHeight/imageSprite.height);
  imageSprite.scaleX = imageSprite.scaleY = myScale;
  var printArea:Rectangle = new Rectangle(0, 0, printjob.pageWidth/myScale, printjob.pageHeight/myScale);
}else{
//-- user cancelled or error occured.
}
printjob.addPage(imageSprite, printArea);
printjob.send();