Click here to Skip to main content
11,716,938 members (79,744 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET PDF convert Word

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 9-May-13 5:30am
Edited 9-May-13 5:32am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
omarbench at 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 at 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.
Omar Benchhiba at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 449
1 OriginalGriff 265
2 F-ES Sitecore 210
3 Maciej Los 135
4 Jochen Arndt 120
0 Sergey Alexandrovich Kryukov 1,144
1 Maciej Los 509
2 OriginalGriff 505
3 Richard MacCutchan 440
4 CHill60 415

Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 3 Aug 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100