Scaling the Printed Output


You might want to scale the output to fill a certain dimension of the printed page, or pages. You have five dimension-formatting choices when adding an object to the print job with the addObject() method. All your options are static constants from the FlexPrintJobScaleType class. This means that to use them, you import the class and then use the constant in the form FlexPrintJobScaleType.CONSTANT. The options are as follows:

  • MATCH_WIDTH: Scales the printed object to fill the page width. If the height exceeds the width, the output will span multiple pages. This is the default setting.

  • MATCH_HEIGHT: Scales the printed object to fill the page height. If the width exceeds the height, the output will span multiple pages.

  • SHOW_ALL: Scales the printed object to fit on a single page, filling one dimension. It selects the smaller of the MATCH_WIDTH or MATCH_HEIGHT and then fills that dimension.

  • FILL_PAGE: Scales the printed object to fill at least one page. It selects the larger of the MATCH_WIDTH or MATCH_HEIGHT scale types.

  • NONE: Does not scale the printed object. The printed page has the same dimensions as the object on the screen.

1.

Open PrintView2.mxml from the flex2tfs_Printing/project/views folder. Notice that only two columns of the PrintDataGrid are displayed, and the width and height of 100% is removed from the previous PrintView custom component.

These changes are made so they don't interfere with the scaling.

2.

Open the file PrintingTask4.mxml from the flex2tfs_Printing project.

This file should be identical to the one you left off with in the last task.

3.

Run the Application. Click the Button labeled Print from the Flex application to print the page.

This will give you a baseline to which to compare other printouts.

4.

In the script block, import the class mx.printing.FlexPrintJobScaleType.

You must import this class to use its static constants.

5.

In the addObject() method, pass a second parameter of FlexPrintJobScaleType.MATCH_WIDTH. Run the application and click the Print Button in the Flex application to print the page.

pj.addObject(myPrintView, FlexPrintJobScaleType.MATCH_WIDTH); 


You see there is no difference between the first and second printouts, confirming that MATCH_WIDTH is the default setting.

6.

Change the scale to FlexPrintJobScaleType.MATCH_HEIGHT in the addObject() method. Run the application and click the Print Button in the Flex application to print the page.

Because the MATCH_HEIGHT was specified to scale to, and the width of the object was greater than the height, the output was spread over multiple pages.

7.

Change the scale to FlexPrintJobScaleType.NONE in the addObject() method. Run the application and click the Print Button in the Flex application to print the page.

Because NONE was specified, the printed output matches the screen, and the output is smaller than your baseline printing from step 3.

The NONE value produced the smaller printed output on the right in the following figure.




Adobe Flex 2.Training from the Source
Adobe Flex 2: Training from the Source
ISBN: 032142316X
EAN: 2147483647
Year: 2006
Pages: 225

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net