开发者

Problems when printing a SWF in browser

开发者 https://www.devze.com 2022-12-20 05:23 出处:网络
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 f

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 t开发者_如何学Pythono 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.


You need to scale your Print Job for what you want in FlexPrintJobScaleType:

MATCH_WIDTH

(Default) Scales the object to fill the available page width. If the resulting object height exceeds the page height, the output spans multiple pages.

MATCH_HEIGHT

Scales the object to fill the available page height. If the resulting object width exceeds the page width, the output spans multiple pages.

SHOW_ALL

Scales the object to fit on a single page, filling one dimension; that is, it selects the smaller of the MATCH_WIDTH or MATCH_HEIGHT scale types.

FILL_PAGE

Scales the object to fill at least one page completely; that is, it selects the larger of the MATCH_WIDTH or MATCH_HEIGHT scale types.

NONE

Does not scale the output. The printed page has the same dimensions as the object on the screen. If the object height, width, or both dimensions exceed the page width or height, the output spans multiple pages.

See http://livedocs.adobe.com/flex/3/html/help.html?content=printing_3.html for more information on this.

0

精彩评论

暂无评论...
验证码 换一张
取 消