Welcome to ESRI Blogs

Print Task templates with the 9.3.1 .NET Web ADF

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.

Viewing the LayoutTemplateFile property for the PrintTask

How do you create a simple custom template?

An easy way to create a template is to modify the ADF's default template.

  1. 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.
  2. Open the default template file which is typically installed in the ADF runtime folder (Example: C:\Inetpub\wwwroot\aspnet_client\ESRI\WebADF\PrintTaskLayoutTemplates\default.htm). This file defines the default appearance and layout of the Print Task output window.
  3. Overwrite the markup of the new page with the contents from default.htm.
  4. 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.

  • Use JavaScript hooks

    In addition to providing extensibility with respect to layout and rendering, the Print Task also exposes JavaScript events which can be used to completely control and customize the output. This is achieved by having "callback functions" defined in the template file which are invoked at specific stages of the output rendering.

Further reading

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.

Published Monday, August 24, 2009 2:45 PM by sterlingdq
Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Print Task templates with the 9.3.1 .NET Web ADF

I am not able to see LayoutTemplateFile at design time. Also any idea how to set this property at Runtime.
Thursday, September 03, 2009 6:35 AM by Hemal

# re: Print Task templates with the 9.3.1 .NET Web ADF

@Hernal-

The LayoutTemplateFile property is like any other .Net property and should be settable in design time and in runtime (Code behind). You could try re-adding/verifying the assembly reference to make sure you are indeed working with the 9.3.1 assembly version. Deleting and re-adding the Print Task control to the Visual Studio toolbox might help also.

Another comment is that if you set the LayoutTemplateFile property at runtime using code behind, it needs to be applied before the OnPreRender phase of the page lifecycle.

Thursday, September 03, 2009 5:07 PM by sterlingdq

# re: Print Task templates with the 9.3.1 .NET Web ADF

i want to change the layout template based on the page size selection. how can i do so?
Monday, September 07, 2009 5:35 AM by Pragnesh

# re: Print Task templates with the 9.3.1 .NET Web ADF

I tried above suggestion but still i dont see LayoutTemplateFile property. It is not available in property dialog for PrintTask control and also at runtime. Only where i can set it is in the source of my aspx page where printTask is dragged. Here inspite of setting it to appropriate template it does not work. I have installed ArcGIS server 9.3 with service pack 1 Also my PrintTask control version is 9.3.1.1850. In this also i am not able to see below folder as mentioned by Nikhil in point 2. C:\Inetpub\wwwroot\aspnet_client\ESRI\WebADF\PrintTaskLayoutTemplates\default.htm
Tuesday, September 08, 2009 2:13 AM by Hemal

# re: Print Task templates with the 9.3.1 .NET Web ADF

I dont see LayoutTemplateFile property and my PrintTask control version is 9.3.1.1850.what you version ? how?
Thursday, September 10, 2009 1:23 AM by lji

# re: Print Task templates with the 9.3.1 .NET Web ADF

9.3 sp 1 is greatly different from 9.3.1, you must install Web ADF runtime 9.3.1 for being able to use this feature.
Thursday, September 10, 2009 8:20 AM by Alessandro Accardo

# Broken Links on web task

Greetings, When I run the print task, some of the images on the layout template have broken links, essentially, pointing to a bogus URL such as: http://esri.arcgis.adf.web.mimeimage.ashx/?ImgID=3a40e9a6cee549a68f929af735b3088d&CacheTime=1&kc=1 What might be causing this error? Thanks, -Eric
Tuesday, October 06, 2009 2:38 PM by Eric Kauffman

# re: Print Task templates with the 9.3.1 .NET Web ADF

I don't see this either, running VS 2005 on 9.3.1. I REALLY need to be able to modify the print task, but I'm no programmer. If any one can help me, send me some info at mundtr@ci.concord.nc.us. Thanks, Rob
Tuesday, November 17, 2009 12:57 PM by Rob Mundt

Leave a Comment

(required) 
required 
(required)