I am currently working on an Adobe AIR application that shows the user some graphical data. As this data is more in height to fit the screen height, I'开发者_如何学Gove placed it inside a scroller.
Now I want to take a print of this visual data, mostly some charts and lists but I only see a single page containing only the part of the screen that is currently visible to the user. I want to have the entire content inside the scroller to appear on the page.
I tried using both PrintJob and FlexPrintJob but couldn't find a way around. Can anyone please help me by providing an insight, some source code will be greatly appreciated.
Looking forward to your replies,
Thanks
This is apparently a known bug with the Flex printing library and Scroller controls. You can read about my discussions on this here: http://forums.adobe.com/message/3626759
As a workaround, I did the following:
var printer:FlexPrintJob = new FlexPrintJob();
// Display the print dialog to the user. If they choose a printer
// and click "print", this method will return true, and we will
// spool the job to the printer they selected. If they hit cancel,
// this method will return false, and we will not attempt to send
// anything to the printer.
if(printer.start()){
// Add some padding before spooling the object to the printer.
// This will give it a reasonable margin on the printout.
itemsToPrintContainer.paddingBottom = 100;
itemsToPrintContainer.paddingTop = 100;
itemsToPrintContainer.paddingLeft = 100;
itemsToPrintContainer.paddingRight = 100;
this.removeElement(itemsToPrintContainer);
FlexGlobals.topLevelApplication.addElement(itemsToPrintContainer);
printer.addObject(itemsToPrintContainer);
printer.send();
FlexGlobals.topLevelApplication.removeElement(itemsToPrintContainer);
this.addElement(itemsToPrintContainer);
// Reset the margins to 0 for display on the screen.
itemsToPrintContainer.paddingBottom = 0;
itemsToPrintContainer.paddingTop = 0;
itemsToPrintContainer.paddingLeft = 0;
itemsToPrintContainer.paddingRight = 0;
}
That I'm doing is moving the object I want to print outside of the scroller, printing it, and then moving it back inside the scroller, so the user is unaware of any change. The user might see a brief flash on the screen while things are re-arranged, but for my case that was acceptable.
Also, the padding was an attempt to add a margin to my printed output. It will not work quite right if you have multiple pages. You may not want to add padding in your particular case.
-Josh
精彩评论