0 Replies Latest reply on Oct 25, 2007 4:08 PM by flashWannaBe

    PrintJob Not Work For Mac?

    flashWannaBe
      Hi there. I'm not sure what I'm doing wrong here but I could use some help. This class is actually being used in a Flex project, but since the process to achieve printing is actually written in AS 3, I posted here. The code works fine on Windows but on the Mac...blank page. Any help would be appreciated. Here is the code:

      package QuizPrint {


      import flash.printing.PrintJob;
      import flash.printing.PrintJobOptions;
      import flash.printing.PrintJobOrientation;
      import flash.display.Sprite;
      import flash.geom.Rectangle;
      import flash.net.URLLoader;
      import flash.net.URLRequest;
      import flash.events.Event;
      import flash.display.Loader;
      import flash.display.Sprite;


      public class QuizPrintHandling {
      public var loader:Loader;
      public var request:URLRequest;
      public var printSpriteReference:Sprite;
      public var pj:PrintJob;
      public var printLoader:Loader;
      public var printJobOptions:PrintJobOptions;


      public function initializePrint(printPath:String):void {
      printLoader = new Loader();
      printSpriteReference = new Sprite();
      printLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
      var request:URLRequest = new URLRequest(printPath);
      printLoader.load(request);
      printSpriteReference.addChild(printLoader);
      }

      public function completeHandler(e:Event):void{
      var pj:PrintJob = new PrintJob();
      printJobOptions = new PrintJobOptions();
      printJobOptions.printAsBitmap = false;
      var pagesToPrint:uint = 0;
      if (pj.start()){
      try {
      if(pj.orientation == PrintJobOrientation.PORTRAIT) {
      pj.addPage(printSpriteReference, new Rectangle(0, 0, 700, 900), printJobOptions, 0);
      pagesToPrint++;
      } else {
      pj.addPage(printSpriteReference, new Rectangle(0, 0, 750, 600), printJobOptions, 0);
      pagesToPrint++;
      }
      }
      catch (error:Error) {
      // Handle error,
      }
      if(pagesToPrint > 0) {
      pj.send();
      }
      }
      }
      }
      }