I have Sharepoint 2007 with a list of browser-enabled infopath forms. I have an aspx page which enables the user to select a date range. When the user clicks a 'Print' button on the page the code behind can process the list of forms, and find all forms for which the form date (a field in the form) lies within the selected date range. Now I want the code to print the found forms. And that's where I come unstuck. I tried code like the following (where urlClaim is a url to the form .xml)
Microsoft.Office.Interop.InfoPath.Application ipApp = null;
try
{
ipApp = new Microsoft.Office.Interop.InfoPath.Application();
XDocument myXDoc = ipApp.XDocuments.Open(urlClaim,(int)XdDocumentVersionMode.xdFailOnVersionOlder);
myXDoc.PrintOut();
}
catch (Exception ex)
{
AddMessage("Print failed with " + ex.Message);
}
Unfortunately the call on Open never returns. But after some thinking I realise that perhaps the InfoPath app can't open the browser enabled form.
So, assuming that using the InfoPath app is the wrong answer, how do I print a browser-enabled form from code?