5 Replies Latest reply on Feb 28, 2011 2:19 PM by Flex harUI

    How to print content inside a scroller in Adobe Air

    flex@relax

      Hi experts,


      I am currently working on an Adobe AIR application that shows the  user some graphical data. As this data is more in height to fit the  screen height, I've placed it inside a scroller.



      Now I want to take a print of this visual data, mostly some charts  and lists but I only see a single page containing only the part of the  screen that is currently visible to the user. I want to have the entire  content inside the scroller to appear on the page.



      I tried using both PrintJob and FlexPrintJob but couldn't find a way  around. Can anyone please help me by providing an insight, some source  code will be greatly appreciated.



      Looking forward to your replies,



      Thanks

        • 1. Re: How to print content inside a scroller in Adobe Air
          Flex harUI Adobe Employee

          Did you submit the scroller's viewport to the printjob?  Don't submit the

          scroller or its parents.

          • 2. Re: How to print content inside a scroller in Adobe Air
            flex@relax Level 1

            Thanks for your answer. I tried using the fix you suggested

             

            Here's the piece of code I used earlier that showed only the visible part

             

                       if (flexPrintJob.start())

             

                        {
                            flexPrintJob.addObject(results.scroller);
                            flexPrintJob.send();
                        }

             

            Now on your advice, I passed the scroller's viewport as the parameter.

             

                        if (flexPrintJob.start())
                        {
                        
                            flexPrintJob.addObject(results.scroller.viewport, FlexPrintJobScaleType.MATCH_HEIGHT);
                            flexPrintJob.send();
                        }

             

            But the results doesn't change. Rather the image that was showing well earlier now got scattered wide on the screen only showing the left half of it now. And still only single page as an output.

            • 3. Re: How to print content inside a scroller in Adobe Air
              Flex harUI Adobe Employee

              You might want to make a print view.  IOW, a copy of the viewport outside of

              a scroller.  The scroller might still be clipping the viewport.

               

              Then try different ScaleTypes.

              • 4. Re: How to print content inside a scroller in Adobe Air
                flex@relax Level 1

                Alex,

                 

                From http://www.darronschall.com/weblog/2005/11/the-secret-to-printing-in-flex.cfm,

                 

                I adjusted my code to

                 

                        if (printJob.start())
                        {
                            FlexGlobals.application.contentGroup.clipAndEnableScrolling = false;
                            results.scroller.viewport.clipAndEnableScrolling = false;
                            setTimeout(continuePrinting, 250)
                        }

                 

                        function continuePrinting():void
                        {
                            printJob.addPage(results.scroller.viewport as Sprite);
                            printJob.send();
                            results.scroller.viewport.clipAndEnableScrolling = true;
                            FlexGlobals.application.contentGroup.clipAndEnableScrolling = true;

                 

                        }

                 


                Now it does print a small portion of invisible portion, but the view of limited to a single page. I observed the contentHeight property of the viewport and it is 6097. But the printout is limited to a single page. I also tried giving a rectangle as the second parameter for the addPage method of printJob giving the height of viewPort.contentHeight but of no use.

                 

                How are you suggesting to create a new view of viewport outside the scroller ? Can you please paste some code for reference for better understanding of your suggestion?

                 

                Thanks

                • 5. Re: How to print content inside a scroller in Adobe Air
                  Flex harUI Adobe Employee

                  I usually have another MXML file that doesn't have scrollbars and is bound

                  to the same data model.