This content has been marked as final. Show 4 replies
This probably isn't the full answer to your problem. However I do know that FlexPrintJob isn't going to wait for your HTTP calls to get a result before it tries to print them. So if you tell it to print the view while it still has a call waiting or is still parsing the result it's going to take it as is whether it's finished or not. My suggestion would be to keep checking for the printJob.start() as your are now and when that matches true, call all of your HTTP services. Then on your final result when it's done parsing, THEN add the view to the printJob (printJob.addObject(thePrintDetailView);) and then finally remove your view and call your send method. I think once this is implemented it will help you in trouble shooting why certain components are / aren't showing up as well as maybe even fixing the issue.
Just my thoughts.
You have to wait until all your objects are loaded and rendered.
From my experience creationComplete event is enough for DataGrids and simple objects. But for Images (and probably for charts as well) you have to wait for creationComplete & updatComplete events, as it after creation they are going to be resized.
I am trying to do something similar and had the exact same problem. I am trying to have a company logo dynamically added to a print job. All attempts at changing the source field on the image tag before printing failed. I tried creating an image object and adding to my print view before printing also failed. The image was generated and displayed on the screen after the print job left the computer. After trying a few ideas, I came up with this one that works but is ugly.
The print job will take a completed object on the screen and add to the print view and then print correctly. So the solution was to create a "hidden" image of the logo when opening the report generator. I placed an image tag ahead of the data grid with both overlappnig on the screen. This makes the image hidden since the data grid comes later in the code. You then start the print job and add the hidden complete image to the print view. this prints correctly. Unfortunately, I found that the addObject function eats the mxml generated image so no second print attempt! To fix that, it turns out that if you generate dyanamically a second copy of the image tag upon opening the report generator, the addObject eats the static version and leaves the dynamically version alone. You can then print with the logo image with no problems repeatedly.
As mentioned, this seems very ugly but I have now printed hundreds of different combinations and it seems to keep working.
If anyone knows of a better solution, I would be very interested.