Skip navigation
jwarmelink
Currently Being Moderated

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

Oct 29, 2009 2:04 PM

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

 
Replies
  • Currently Being Moderated
    Jun 13, 2012 4:07 PM   in reply to jwarmelink

    Were you able to solve this problem?

    I am currently having the same problem as yours... I created my own printing classes that do all crazy calculation to figure out page breaks and stuff... everything goes well until the point I want to add these pages to the printJob. I get same error?

     

    Any help is highly appreciated.

     

    Thanks,

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 3:29 AM   in reply to Barjawi

    I had this error when printer was disconnected (it took a while before I realised this )

     
    |
    Mark as:
  • Currently Being Moderated
    May 22, 2013 3:33 AM   in reply to Barjawi

    I just had the same error, restaring printer and reconnecting it to usb sovle the problem.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points