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.

ADVERTISEMENTS

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.

 
 Subscribe via RSS or Email

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 of S.Y.M. Wong-A-Ton. 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, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related Posts

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services