views:

1817

answers:

7

I need to take a Word document that is a template of sorts...collect user input to populate specific fields in that template..then generate a PDF file that includes the completed template as well as a few other document types. Does anyone have a good suggestion on a component to achieve this? Preferably one that does not require Microsoft Office to be installed on the web server.

A: 

Is there a reason to use Word? If you start with a PDF with Form fields, you can either allow the user to fill out the fields, or do it programatically with iTextSharp's PDF stamper.

If you need to use MSOffice 2000/2003 components programmatically, you can try Office Web Components. They do need to be installed on the server, but can be used by .NET and Com apps to interact with office file types. More info here...http://en.wikipedia.org/wiki/Office_Web_Components

If you dig about on an office CD you should find the OWC installer for your version. I haven't worked with 2007, but I assume there is something similar available.

iTextSharp and OWC are no-cost, check the licensing for more details.

StingyJack
The only reason we'll be using Word is for the users' ease of use. These templates change on a some what regular basis, so they need to be able to change them and most of the users only have PDF Reader software installed. Thanks for your advice though. :-)
Tyler
A: 

Hmmm...You might be able to employ CutePDF printer in a creative way to solve this problem. Essentially, it takes anything that can be fed through a standard print driver and makes a PDF out of it. It's free.

BKimmel
I am familiar with CutePDF since I use it personally to print many things to PDF. I've never thought about using it in a server environment. I'll definitely think about that.
Tyler
+2  A: 

Try Aspose Words for .net. From their website: "Aspose.Words enables .NET and Java applications to read, modify and write Word® documents without utilizing Microsoft Word." Utilizing Aspose Words with Aspose PDF permits you to output to PDF.

One thing you do NOT want to do is install MS Word on your production server. Loading those objects is SLOW and EATS memory. You won't be able to use the CutePDF Writer unless you also install MS Word on the server. Yeck.

Robert C. Barth
A: 

Try using The Apache POI API to populate the fields. It can get into Word documents and access their elements.

As for the Word -> PDF step, I'd also recommend evaluating the Aspose solution. It may even be able to perform both steps. Its not free, however.

mieze
A: 

My first thought for a "doc template" + merge to pdf solution would be to start with open office formats. - the odt file (open document template) is xml-based - so you could even use perl, to do the merge, then call writer's doc 2 pdf (I have no idea if they have an API, but one could find out in less than a day - even if one had to examine the source.)

and converting your "word" dot to a writer odt file is just a "file save as" operation in OoWriter.

jbdavid
A: 

If you use Aspose.Words, then your input document/template can be in one of the several supported formats including DOC, DOCX.

Then you can insert data into the document in a number of ways. You can use bookmarks in a document and just set their text. Or better yet use the reporting engine we provide. It allows to use standard MS Word MERGEFIELD fields plus adds capabilities for repeating regions and even nested. E.g. you can design an invoice (with parent/child data) template in MS Word and then populate from a .NET DataSet in one line of code.

Also, you only need Aspose.Words to produce PDF (a year ago you needed both Aspose.Words and Aspose.Pdf). You can also easily save the exactly the same looking document to DOC, DOC, DOCX and a few other formats.

I'm on the Aspose.Words dev team.

romeok
A: 

Have a look at the Muhimbi PDF Converter Web Services. It runs on Windows as a service, but can be accessed from any non-Windows web services capable environment including Java and .NET.

Although this solutions requires MS-Office to be installed on a server (not necessarily the same server as your application), it is very robust and provides perfect conversion fidelity.

To generate or Modify MS-Word files I recommend using the free Open XML SDK for Microsoft Office. Eric White maintains a really good Blog about it.

Disclaimer, I worked on this product. Having said that, it works great.

Muhimbi