Creating pdf
in my project when click a button i need to open a new pdf file, in that file contain values from my database. how to create it. please help me
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Anupam SinghRank #643 · 3.7K reputationPosted Jun 15, 2014, 6:41 AM EDT
http://www.codeproject.com/Articles/81118/ITextSharp-Helper-Class
Rahul PrasadRank #2,557 · 546 reputationPosted Jun 30, 2014, 7:09 PM EDT
http://www.codeproject.com/Questions/385812/How-to-export-data-to-PDF-using-csharp
Glen Lewis14 reputationPosted Jul 9, 2014, 12:04 AM EDT
You see this second approach is more common, you could create a word (DOCX) or template (DOTX) document in .NET which will define some place holders and then you can fill them with database data and convert the document to a PDF.
I also used this approach with a help of this .net dll for word and other document type file processing, more specific I used MergeField elements in DOTX file and then execute a mail merge operation in C# to import new data, after that I save the document into a PDF format.
Also just in case if that approach does not suit your needs, here is a sample how to create a new PDF file with DataTable's data:
var dataTable = new DataTable(); // ... var document = new DocumentModel(); document.Sections.Add( new Section(document, new Table(document, dataTable.Rows.Count, dataTable.Columns.Count, (r, c) => new TableCell(document, new Paragraph(document, dataTable.Rows[r][c].ToString()))))); document.Save("New File.pdf");