TheBoubou
TheBoubou

Reputation: 19903

Generate PDF document based on Word document

I’d like in an ASP.NET MVC application generate document (invoice for example) based on a word document than I use as template. I create a word document with :

Some fix data :

Some data to add in a specific place :

In this document, I can create a kind of tag, example <PDF:InvoiceNumber> and replace it by the value by code, same for all the other "TAG"

Do you have an idea how I can do this? Did you experiment another way (suggestions are welcome)? I accept to use 3rd control free or commercial. The only restriction is … I don’t want install Microsoft Word on the server.

Thanks,

Upvotes: 1

Views: 1590

Answers (2)

Jeroen Ritmeijer
Jeroen Ritmeijer

Reputation: 2792

I realise you don't want to install MS-Word on the server, but you could consider installing it on a separate machine and then consider the approach in this article. It uses Web Services and is clean and efficient.

I wrote this article so the usual disclaimers apply.

Upvotes: 0

sbohlen
sbohlen

Reputation: 2019

Use the OSS .net port of iText, iTextSharp (google or bing for it).

General process: 1) Create a PDF file of your existing Word Doc

2) Using Acrobat (or similar tool) add PDF form fields to the file as placeholders for the data you will insert into the form at run-time

3) Using iTextSharp 's PDF form-filling API, insert the data into the form-fields in the PDF

4) Save, print, return-as-stream-to-client's-browser-with-PDF-mime-type, etc. the resulting PDF

Upvotes: 3

Related Questions