2 Replies Latest reply on Nov 18, 2010 11:13 PM by kirti kishan

    Problem for printing component in Flex with header and footer?

    kirti kishan

      Hi All,

       

      I have been working on printing in Flex since couple of weeks. I have been stuck at priting an custom component with header and footer. In my case i have an custom Accordian which and when the tabs are clicked will open up to heigh = 2500. i.e when i print it will print upto 4 pages. Now the problem that i was facing is printing that Accordian on each page with header and footer i.e. my print page size is 800 and i need to print the first 0 - 800 in first page and 800 - 1600 in second page and so on. Here the main problem is to print it with header and footer on each page. Any One has a solution to it as the requirement is quite urgent. Thanks in Advance !!

        • 1. Re: Problem for printing component in Flex with header and footer?
          Abhinav Sharma Level 2

          i m not getting you properly. If you can provide me the

          code then it will be great.


          • 2. Re: Problem for printing component in Flex with header and footer?
            kirti kishan Level 1

            Hi Abhinav,


              please look at the code:

             

             

             

                            var printJob:PrintJob = new PrintJob();
                            var options:PrintJobOptions = new PrintJobOptions();
                            options.printAsBitmap = false;

                            var numPages:int=0;           
                            var tmsAnalysisDashboard : TmsAnalysisDashboard = (rightPanel.tabNavigator.selectedChild as ReportTabContainer).getChildAt(0) as
                            TmsAnalysisDashboard;

             

                                // drilldown_comp is the Accordian which we are go going to print, The height of this component will go beyond 2500px.


                            var drilldown_comp:DrillDownComponent = tmsAnalysisDashboard.middleCont.removeChildAt(0) as DrillDownComponent;
                            if(printJob.start())
                            {

             

                                 // i need to add this component to top most chuild of the stage since this gets masked by other components when printing.


                                stage.addChild(drilldown_comp);                  
                                var pageHeight:int = printJob.pageHeight;
                                var pageWidth:int = printJob.pageWidth;
                                var paperHeight:int = printJob.paperHeight;
                                var paperWidth:int = printJob.paperWidth;

                                   // to calculate no of pages ... here it is 2500/800. numpages=4


                                numPages = Math.ceil(tmsAnalysisDashboard.drildown.height/printJob.pageHeight);                        
                                tmsAnalysisDashboard.drildown.scaleY = tmsAnalysisDashboard.drildown.scaleX;                
                             
                               
                                /* Add pages to print job */
                                for (var i:int = 0; i < numPages; i++)
                                {
                                    var printArea:Rectangle = new Rectangle(-60,-50,pageWidth,pageHeight);                 
                                    printJob.addPage(drilldown_comp, printArea,options);
                                    printArea.y += printArea.height;
                                   
                                }


                                /* Send print job to printer */
                               
                                printJob.send();

             

                                // after printing is done the component is removed from the stage and is put back to the original parent.


                                stage.removeChild(drilldown_comp);
                                tmsAnalysisDashboard.middleCont.addChild(drilldown_comp);

             

             

             

             

            Hope you understand the code!

             

            Here i need to print that component with header and footer on all the pages.