The 9.3.1 ArcGIS Server Web ADF for .NET introduces an extensibility point to the Print Task that allows you to customize the look of your printouts using template files on the Web server.
A new property called LayoutTemplateFile is introduced to define the template file. This property can point to any file on disk but must be accessible via a web URL. The file may be part of the same application or can reside in a separate application (for example, the aspnet_client folder).
In Visual Studio, select the PrintTask control and you’ll see the new property. Clicking the Browse button allows you to browse to the custom template file.
How do you create a simple custom template?
An easy way to create a template is to modify the ADF’s default template.
- Within Visual Studio, right-click your project and choose “Add New Item…” from the menu. When the dialog appears, choose “HTML Page” and give it a suitable name. This will create an HTML document which you can use as the template.
- Open the default template file which is typically installed in the ADF runtime folder (Example: C:Inetpubwwwrootaspnet_clientESRIWebADFPrintTaskLayoutTemplatesdefault.htm). This file defines the default appearance and layout of the Print Task output window.
- Overwrite the markup of the new page with the contents from default.htm.
- Modify the markup and CSS to obtain the output you desire.
What can you do with these custom templates?
Using custom templates, you can:
Control the layout of elements and their styles
In the template file, you can define the position and dimensions of the different elements on the page such as the map title, map image, and legend information. You can style the template page using inline CSS or an externally linked style sheet.
Inject dynamic content
The template file is not restricted to static HTML files but can reference resources which generate dynamic content (such as .aspx files or .ashx files). For example, the current time stamp could be included in the print output using a dynamic page.
Control the display of results
You can control the styling of task results through CSS and you may also choose to render the result entirely, forgoing the default generated table view. If you want to get more advanced, you might add an image generated using the Google Chart API or a report section rendered using a browser plugin like Silverlight.
The SDK sample Common Print Task demonstrates the above capabilities where a chart is drawn dynamically using the Google Chart API
Contributed by Nikhil Shampur of the ArcGIS Server .NET software development team.