Ronnie
Ronnie

Reputation: 1079

Populate a form and print out document

I have a word document which is a blank form. I need to be able to fill it in programatically using .NET, and print out the result.

The form I have is a Word document, but I could obviously convert this to PDF if it is needed.

Upvotes: 2

Views: 1409

Answers (3)

Gishu
Gishu

Reputation: 136613

As Josef said, if it's OpenXML (Office 2007) document you can use the managed .net classes to easily update the document, which is basically modifying a bunch of xml files, zipped and renamed to .docx . Visual Studio tools for Office (VSTO) should help you out if need be for Office 2000 and 2003. For previous versions of office you'd need to use Office Automation COM Classes..

Now for updating fields in the word document, you'd need to identify where to insert text to. So if you have some bookmarks or markers to identify the places where you'd like to insert text... you can seek to that position and insert text. Printing the word doc should be simple since Word has printing support built in. Should be as easy as calling the right method.

Upvotes: 0

jro
jro

Reputation: 7480

Are you working on the client-side or the server-side?

Client-side: start looking at Visual Studio Tools for Office.

Server-side: this one is difficult. My advice is don't run the client-side office libraries in a server environment. I'm working on this right now, and if you're in this boat, don't do it. Look for a client-side library.

Upvotes: 0

Jozef Izso
Jozef Izso

Reputation: 1804

Do you have Word document in Open XML format or is it in old binary format?

In Open XML this task can as easy as manipulation of XML inside a package (ZIP file).

If you have binary Word file this can be tricky. You will need to use .NET Programmability Support for Office and Microsoft.Office.Interop.Word namespace.

Upvotes: 1

Related Questions