Converting browser-enabled forms to PDF or HTML in SharePoint
Learn which options are available when it comes to converting or saving an InfoPath browser form to HTML or PDF within SharePoint.
As you may already know, the InfoPath Object Model contains a method called Export on the View class, which represents a view in an InfoPath form.
You can pass an ExportFormat to this method. Export formats include: MHT, PDF, and XPS.
So if you have an InfoPath Filler form and want to convert one of its views into PDF, you can pass the PDF export format to the Export method. And if you want to convert a view of the form into HTML, you can pass the MHT export format to the Export method.
Unfortunately, the Export method is not available when you are designing and writing code for an InfoPath browser form. Therefore you must find an alternative for converting the view of a browser form or the entire form to PDF or HTML.
Recipe 101 of InfoPath 2010 Cookbook 3 shows you how you can use Word and Word Services in SharePoint to convert an InfoPath browser form to a PDF document. You could also use a third-party component (see for example this InfoPath 2007 article: Print InfoPath to PDF in SharePoint) to convert an InfoPath browser form into a PDF file.
Where converting an InfoPath browser-enabled form to HTML is concerned, you can combine the techniques discussed in recipes 95 and 98 of InfoPath 2010 Cookbook 3 to create a solution that uses a print view to save data from the InfoPath form as an HTML file in a SharePoint document library.
Such a solution does not make use of SharePoint programming, is fairly quick and easy to set up, and is based on 100% InfoPath programming that does not require Full Trust, i.e. the form template can be deployed as a sandboxed solution to SharePoint.
One caveat of this save InfoPath form as HTML solution is that images are not embedded in the HTML file as they would normally be in an MHT file. Therefore, such a solution would only support images that are stored as links in the InfoPath form instead of as base64-encoded strings.
The InfoPath/SharePoint video shown below demonstrates how the final solution would work.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.