2 Replies Latest reply on Jul 14, 2010 9:59 PM by BhaskerChari

    How to print text/data in flex 3 using printer???Plz help...



                plz tell me the way to print text/data using printer in flex.  I tried the FlexPrintJob class. but it takes object of a container to be printed & prints the visible content of that container(along with scrollbars), bt i want to print all contents of the container(including invisible).

            I have tried to print bitmap image through FlexPrintJob but it takes lot of time for spooling... So plz help me out in printing(fast with all content) in flash

      I am using flex 3 (flex Builder 3 IDE).

        Thanks in advance!!!

        • 1. Re: How to print text/data in flex 3 using printer???Plz help...

          Sorry to answer a question with a question, but what do you mean by "invisible" content?

          • 2. Re: How to print text/data in flex 3 using printer???Plz help...
            BhaskerChari Level 4

            Hi Sagar,


            Don't worry You can use the below work around to print all the contents of the Container including the invisible contents under scrolll with out scroll bar..


            So what the idea here is we are seeting the container height to full size with out scrolls before sending the container object to printer and as soon as you print the object you are restoring it to the original height with scrolls...so that you can print the full contents without scrolls...


            You may have doubt that by chnaging and restoring the size the user may see momentary resize of the container but it is not so as it is a fraction of a second and user cannot notice this change... Give it a try ..I had already run into this problem recently and I have found a work around for this which is as below:


            // Here mainContainer is the container or box id the contents of which you want to print
               private function doPrintContainer():void
                var printJob:FlexPrintJob = new FlexPrintJob();
                if(printJob.start() != true) return;

                 var mainContainerHeight:int = mainContainer.height;
                 //Increasing the height of the desired component to be printed.
                 mainContainer.height = mainContainer.measuredMinHeight;
                 mainContainer.verticalScrollPolicy = "off";

                 //Adding the resized Component to our FlexPrintjob and then sending the print request
                 //Resizing the component back to normal size
                 mainContainer.height = mainContainerHeight;
                 mainContainer.verticalScrollPolicy = "auto";    
                             trace("Error : " + error.message);



            If this post answers your question or helps, please kindly mark it as such.


            Bhasker Chari

            1 person found this helpful