Printing InfoPath 2007 Web-Based Forms to PDF
page 3 of 8
by S.Y.M. Wong-A-Ton
Feedback
Average Rating: 
Views (Total / Last 10 Days): 47599/ 74

Overview of Printing Web-based Forms to PDF

InfoPath forms are XML files, so to print a web-based form to PDF you must retrieve the XML of the form and convert it to PDF. Retrieving the XML of a web-based form can be a challenge since such forms are hosted in a control on a web page. A web-based form can be hosted by:

1.    Using the InfoPath Forms Services web page to host the form.

2.    Creating a custom ASP.NET page to host the form.

In both cases, a control named XmlFormView is used to host the form on a web page. The difference between the two methods is that while you have total control over a custom web page that you create, you do not have the same amount of control over the web page that is used by InfoPath Forms Services, since its code-behind is inaccessible to you. In addition, it is not recommended to modify files that are used by InfoPath Forms Services, since they might be overwritten by future upgrades of Forms Server or Microsoft Office SharePoint Server. It is recommended that you create your own custom ASP.NET page, which uses an XmlFormView control to host your forms.

The XmlFormView control has a property named XmlForm, which gives you a reference to the main data source of the form and allows you to retrieve the XML of the form. However, the XmlForm property can only be accessed during one of the following events of the XmlFormView control:

·         Initialize

·         NotifyHost

·         SubmitToHost

·         Close

The NotifyHost event is suitable for setting up communication between the form and the ASP.NET page that is hosting it. To trigger the NotifyHost event, you must use the NotifyHost method of the XmlForm class in an event handler of a field on the form. You can then hook up the NotifyHost event to an event handler in the ASP.NET page, retrieve the XML of the form, and convert the XML to PDF.

The technique presented in this article uses the NotifyHost method and event to enable printing web-based forms to PDF. An overview of how this technique works is shown in Figure 1 and is discussed in more detail in subsequent sections.

Figure 1: Overview of printing a web-based form to PDF


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 7:40:40 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search