3 Replies Latest reply: May 22, 2013 3:33 AM by dfm_ RSS

    Error #2057: The page could not be added to the print job.

    jwarmelink Community Member

      I've been making myself crazy over this one.  I'm trying to print a complex multi-page "report" in Flex, but I keep getting this error every time I try to call FlexPrintJob.addObject(page):

       

      Error #2057: The page could not be added to the print job.

       

      Here is the basic scenario...  I have created a new control I call a PrintVBox that extends the normal VBox control.  After adding all of the children properly to the component, I wait for an update event (so that the heights of all the components are calculated) and then I call a custom method I have added to PrintVBox that "paginates" the control.

       

      This pagination method essentially decides how many of the items in the VBox can fix on each page, and splits them up into separate pages.  Here's a somewhat graphic example of what happens:

       

      (before paginate)

      ***** PrintVBox ********

       

           [ Item 1 ]

           [ Item 2 ]

           [ Item 3 ]

           [ Item 4 ]

           [ Item 5 ]

       

      ***************************

       

      This single VBox with 5 items, after calling the paginate method becomes something like this:

       

      (after paginate)

      ****** PrintVBox ********

           **** VBox (page1) ******

                     [ Item 1 ]

                     [ Item 2 ]

           ****************************

           **** VBox (page 2) ******

                     [ Item 3 ]

                     [ Item 4 ]

                     [ Item 5 ]

           ****************************

      ****************************

       

      So, what was once a single VBox with 5 UIComponents on it is now a VBox that contains two VBoxes, each the exact size of a printable page, one containing the first two items, the other containing the second two items.

       

      In my example that I am working on, my PrintVBox that I have created uses a Repeater to create about 20 HBoxes on the page.  I then call

       

      myFlexPrintJob.start()

       

      to show the print dialog and get the user's parameters.  I then pass the chosen print height and width to the PrintVBox control and call the paginate method, which creates pages of the desired width/height.  I have tested this part thoroughly and displayed the resulting PrintVBox on the screen and it paginates successfully and all is well.  After paginate, it has created 3 page VBoxes each holding some of those 20 items.

       

      I then iterate thru PrintVBox.getChildren() array, in this case which is the three VBox pages, and I call:

       

      myFlexPrintJob.addObject(page);

       

      for each one.  Each one errors out with the above error.  The error is down in the PrintJob code, which is part of the Flash framework and I cannot step through it.  I have no indication of why the page can't be added to the print job.  Is there a reason this is happening??  Does it have to do with the Repeater that originally created the 20 HBoxes, even though I have now moved those HBoxes down onto separate pages?  I'm just so confused here.

       

      I can probably post the entire code chunk if someone really wanted it.  I'm currently testing it as an AIR application using a big tester XML data object on the repeater, so that I didn't need a database and such to create the control and test printing.  If someone really wants to see what I'm doing, let me know.

       

      HELP! PLEASE!!

       

      Thanks,

      Joe