Archive for March, 2008

Getting rid of those pesky Flex printing artifacts

If you’ve ever wrestled with Flex’s printing classes, you’ll know how much of a pain they can be, especially with multipage output.

You spend hours trying to get Flex to scale things properly, and when you finally succeed, you’re left with pages with mysterious 2 pixel wide lines at the bottom or side. It turns out that Flex has a slight problem guesstimating the size of the output on the page, and accidentally leaks part of your application background onto the page.

If you’re using the default styles for your application, then there’s a simple fix for this. Before you call printJob.start(), you need to turn off the background gradient, like so:

Application.application.setStyle("backgroundGradientAlphas", [0, 0]);

Then after the print job completes (or was cancelled), turn it back on:

Application.application.setStyle("backgroundGradientAlphas", [1, 1]);

Of course, if you’re using something other than the default background, then you’ll probably need to store the old styles, turn the background off, then retrieve and re-set the old styles again.

AddThis Social Bookmark Button
Comments (1)