Autodesk 15606-011408-9300 Developer Guide - Page 81
Print Event Handler Example, To add a custom symbol to the printout
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 81 highlights
Print Event Handler Example If you want your application to change the title font, you can add a custom symbol, or control the position and size of any page element. To do this, you need to write event handling code that responds to the onEndLayout event. When onEndLayout is triggered, it automatically passes two objects, MGPrintLayout and MGPrintInfo objects: void onEndLayout (MGPrintLayout prLayout, MGPrintInfo info) The MGPrintLayout object provides access to printed page elements. You can then use MGPageElement and MGExtentEx to control how those elements display. The MGPrintInfo object provides information about the resolution of the output device and the size of the printable area of the page. The following example shows one way to write a print event handler in JavaScript that adds a custom symbol (myLogo)to the printout. The example assumes you've set up the event handlers as described in "Setting Up Event Handlers" on page 72, and enabled print events as described in "Enabling the Print Events" on page 66. To add a custom symbol to the printout 1 Create a button on the HTML page: 2 Create a JavaScript function that the button will call. In this example, the function sets the state of a boolean variable called new_symbol. The variable will be read by our event handler, so we've given it global scope by declaring it outside the function body: var new_symbol; // put var outside function body function print_map_only() { new_symbol = "true"; getMap().printDlg(); new_symbol = "false"; } Writing Event Handlers | 81