Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET PDF convert Word
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 9-May-13 6:30am
Edited 9-May-13 6:32am
v2
Rate this: bad
good
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.
  Permalink  
Comments
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 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Maciej Los 250
3 Shweta N Mishra 216
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 3 Aug 2013
Copyright © CodeProject, 1999-2014
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