Convert an InfoPath form to Word and PDF in SharePoint 2010

In this InfoPath demo video you will see how you can use Word Automation Services in SharePoint 2010 to convert a Word document that has been automatically generated based on data from an InfoPath 2010 form into a PDF document.

In recipe 101 you'll learn how to write C# code in Visual Studio 2010 that can convert an InfoPath form into a Word document and then schedule a job for Word Automation Services to generate a PDF document from that Word document.

Get more solutions from InfoPath 2010 Cookbook 3 which is available on Amazon.com
OR
Watch next video: Use an InfoPath form to add a recurring all day event to a SharePoint calendar

InfoPath demo video transcript:

Here I'm in SharePoint 2010 and I've already published a form template to this form library. The intention is that I will be filling out this InfoPath form, which as you can see has already been prefilled with some data.

Once I save this InfoPath form back to the SharePoint form library, a SharePoint event handler will run and it will grab this Word document template, which is located in this DocLib document library, and use it to generate a new Word document based on the data that was stored in the InfoPath form and the data that is present in this Word document template.

Then after a couple of minutes Word Automation Services will run and grab the newly created Word document and generate a PDF document from it.

This Word document template is a simple document that contains text and a couple of fields that will be filled in.

So if I add a new form and fill it out... Let me add a new skill here... SQL Server... Intermediate to advanced... 14 years.

I'll select as table style... This table style is just the table style that will be applied to this table in the Word document. I'll select Table Classic 1.

And I'll also add a couple of line-breaks to this text to make it more legible. And I'll add a logo to the document.

So if I now save the form back to the form library, you'll see that when I go to this DocLib document library, a new Word document has been generated. And if I open it, you'll see that it contains the data that I entered into the InfoPath form along here with the line-breaks and the image.

I'll add a new form just to show you the difference between the table styles. And I'll change this to Netherlands... 31... 60. And I'll select this Light Shading - Accent 1. I'll leave this text not to have any line-breaks. And then I'll add an image. And then I'll save this form as form02.

And then when I go to the DocLib document library, there is a form02 Word document, and then as you can see this one has a different table style as the previous document.

I'll open the other document just to show you that is indeed the case. So this is a different table style than in the other document.

So now we'll wait a couple of minutes for Word Automation Services to kick off and generate the PDF documents.

After 10 minutes...

Word Automation Services has run and as you can see it has created two new documents in the DocLib document library. I'll save these documents locally. And then when I open them, you'll see that this is the first CV that I created and this is the second one.

 

Related InfoPath Demo Videos:

 

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.

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

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers