2 Replies Latest reply on Mar 26, 2015 1:38 AM by raghavank

    Flex Print Job not working with custom component

    jigarinu

      Hi All,

      I have to print pages with header, body and footer. So the thought process was to create a custom component fro header, footer and body. Header component is based on Box, Body is a renderer (which will have fix value of items - and will decide the number of possible pages) and footer is again based on Box.

       

      But when i created a simple Custom component like this for header

       


      <?xml version="1.0" encoding="utf-8"?>

       

      <mx:VBox  xmlns:fx=http://ns.adobe.com/mxml/2009

        xmlns:s="library://ns.adobe.com/flex/spark"

        xmlns:mx="library://ns.adobe.com/flex/mx">

       

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      </fx:Declarations>

       

      <mx:HBox>

       

           <mx:Label id="testLabel" text="Test Container"/>

      </mx:HBox>

       

      </mx:VBox>


       

      Then when i try to add this to FlexPrintJob, and save it as 'xps' to see the print output, i get error message that this file is in use or damaged.

       

       

        var myPrintJob:FlexPrintJob = new FlexPrintJob();
         if(!myPrintJob.start()){
            return;
           
      } 
       var header:Header = new Header();
      header.width = myPrintJob.pageWidth;
      header.visible = false;
      FlexGlobals.topLevelApplication.addChild(panierPrintHeader);
      myPrintJob.addObject(header);
      myPrintJob.send();
      FlexGlobals.topLevelApplication.removeChild(panierPrintHeader);
      
      

       

       

       

       

      But this does not work and i get the above mentioned exception. Now when i not

      use the custom component and just have a label or HBox or anything on stage before the print functionality is invoked, it works fine. And this too haapens only if you have a mxml component, i tried by creating a new Label component using actionscript and then provide the same to the printJob, which did not work either. I need help on this, else i will have to take print functionality to server side(Java) which has some business implications, the reason why i am spending time on flex for printing.

       

      Thanks and Regards,

      Jigar

       

       

       

       

       

       

       

       

       

       

       

       

      Looks like custom component print is not working fine with flex or i am doing something terribly wrong.

       

      Looking forward for help.