To implement the technique discussed in this article, you
must either design a new browser-compatible form template or modify an existing
one. The form template shown in Figure 2 is used throughout this article. It is
browser-compatible and has the Main data source shown
in Figure 3. The Print to PDF button control on the
form template has a Clicked event handler with the code
shown in Listing 1.
Figure 2: Sample InfoPath form template

Figure 3: The Main data source of the sample
InfoPath form template

Listing 1: Code for the Clicked event handler of
the button control
public void btnPrintToPDF_Clicked(object sender, ClickedEventArgs e)
{
NotifyHost("PrintToPDF");
}
Since the form template contains managed code, you will have
to perform an administrator-approved deployment when you publish it to a
SharePoint server running InfoPath Forms Services, and browser-enable it.
For more information on designing and publishing
browser-compatible form templates, see the following articles:
·
Introduction
to browser-compatible form templates
·
Publish a
form template to a server running InfoPath Forms Services
·
How to: Deploy
Form Templates That Contain Form Code