Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a database(SQL Server) with thousands data items(each item is a trainee with all his informations), and a predefined word document as template, the requirement is - for each trainee- (Who's loggedon), fill corresponding data(trainee informations) into template fields, and generate a readonly PDF file as result.

Platform is ASP.NET(C#).

I found two solutions:

1. Change the word document into a PDF form, and use iTextSharp to fill the form fields. But create the PDF form with correct format (font, layout, etc.) is a difficult work, and it needs particular tool and new skill when system user wants to add new template (unless the PDF form is always created by developer).

2. Add text placeholder in the word file, and the program can read word file, replace text, and convert into PDF. but i don't know how to proceed.
Posted
Updated 9-May-13 5:32am
v2

Or, you could just do the entire thing in Word. What you're describing is called "Mail Merge" and you can print the entire document to a PDF "printer" without a single line of code.
 
Share this answer
 
Comments
[no name] 9-May-13 12:09pm    
Thank you for your answer !

No it's not mail merge



for example i'm logged as a user so in the database there is all my informations, so when i want to get the document i just have to get the document with only my informations in it with also some informations that i filled in a form that's all
Dave Kreskowiak 9-May-13 12:11pm    
Yeah, it's still a mail merge. The query you give to the mail merge is only going to return one record.

If you have a Word template, you're going to be doing the exact same thing. You tell Word to do a mail merge, give the query for the one record, and tell it to print to a PDF printer.
[no name] 9-May-13 12:18pm    
OK I'll give it a try right now thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900