I'm trying to print a SWF and have come across some problems. When using the Print function in the browser, the SWF will be distorted, and not scaled correctly. So I've tried to implement a Print function using Actionscript instead.
The different approaches I've taken are:
- Printing using the right click context menu of the Flash Player and choose Print. This works almost as expected, but It flattens transparent PNGs and isn't scaled correctly.
- Creating a FlexPrintJob and adding the component to the job. Will not scale the component to fit the page, even though I've set FlexPrintJobScaleType.SHOW_ALL on the print job.
- Creating a PrintView containing an Image. Then taking a screenshot of the component and set this as the Image in the PrintView. When this is done, I create a new FlexPrintJob and send it. This seems to work most of the times, but the scaling will distort and make small elements (like text) look really bad.
The code for printing looks like this:
var pj:FlexPrintJob = new FlexPrintJob();
if (pj.start())
{
pj.addObject(componentToBePrinted, FlexPrintJobScaleType.SHOW_ALL);
pj.send();
}
What I would like to do is to get the right click context menu to work, and by that I mean setting the scaling of the SWF. Is this possible? Are there any other alternatives when printing a SWF? What am I doing wrong?
When testing, I'm printing to a PDF, but I don't think that will change the results.