6 Replies Latest reply on Aug 17, 2006 12:01 PM by ReLLiK75

    problems printing Images

    pkleppner Adobe Employee
      I have a PrintJob (or FlexPrintJob) that attempts to create and render a new mx.controls.Image instance at print time. The Image never appears on the printed page. However, An Image that was previously rendered on the screeen, before the print job is started, will print correctly.

      I'm assuming the problem with the Image created a print time is that it is not given the opportunity to load itself before the printing occurs. As best I can determine, all loading is suspended while printing takes place, and I haven't found any way to defer or delay the printing.

      I know I can work around this by preloading all the Images before I start the print job, but that's not very desirable. Are there any other work-arounds to this situation?
        • 1. Re: problems printing Images
          frickin_chicken
          i had the same problem. i dont think this will be my final soln but this solves the problem you are talking about... as i understand it at least. It uses the loader class and its complete event. hope this helps.

          private var s:Sprite;

          private function init():void{
          s=new Sprite();
          }
          private function qod():void{
          var loader:Loader = new Loader();
          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
          var request:URLRequest = new URLRequest("mypic.png");
          loader.load(request);
          s.addChild(loader);
          }
          private function completeHandler(e:Event):void{
          var pj:PrintJob=new PrintJob();
          pj.start();
          pj.addPage(s);
          pj.send();
          }
          • 2. Re: problems printing Images
            ReLLiK75 Level 1
            I'm trying to do the same thing, with the exception that I need to print multiple images with only one print dialog, where as your code will display a print dialog for each image that is printed. Any ideas?
            • 3. Re: problems printing Images
              frickin_chicken Level 1
              i ended up making a class that did all that stuff. if i remember correctly i...

              a - made an array of urls
              b - populated an array of sprites with the loaded images
              c - started the print job
              d - used addPage to add all the sprites in the array
              e - called the send method.

              is it the best soln? i dont know to be honest. im new here. but... it does work so far.
              • 4. Re: problems printing Images
                jpwrunyan Level 1
                I was just thinking how to do this the other day and the above idea looks good (for printing multiple images) but I want to know, did your sprite array actually get displayed on screen (via addChild() or something)? In Flex 1.5/Flash 7 you had to load stuff onto stage to print it (whether it was loaded onto a visible part of the stage or not). If all you have to do is initialize the visual information (without showing it on stage) then that would be awesome.
                • 5. Re: problems printing Images
                  frickin_chicken Level 1
                  yeah i hear ya. that was actually one of the requirements when i created this soln. the sprites are never displayed. if you guys want my class ill forward it over to you. i guess you can send me your emails privately or something.
                  • 6. Re: problems printing Images
                    ReLLiK75 Level 1
                    frickin_chicken, PM Sent

                    Thanks!