Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone...

Is there anyone created a report using iTextshap taking data from sql database? i was bizy searching for the solution online with no luck...

Please if you have a code you are more than welcome to post it or put a link

Please Please Please Help....
Posted

 
Share this answer
 
Document doc = new Document(iTextSharp.text.PageSize.A4);
            System.IO.FileStream file = new System.IO.FileStream(Server.MapPath("~/PDF/PdfSample") + DateTime.Now.ToString("ddMMyyHHmmss") + ".pdf",System.IO.FileMode.OpenOrCreate);
            PdfWriter writer = PdfWriter.GetInstance(doc, file);
           
            doc.Open();
            PdfPTable tab = new PdfPTable(3);
            PdfPCell cell = new PdfPCell(new Phrase("Header",
                                new Font(Font.FontFamily.HELVETICA, 24F)));
            cell.Colspan = 3;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            //Style
            cell.BorderColor = new BaseColor(System.Drawing.Color.Red);
            cell.Border = Rectangle.BOTTOM_BORDER; // | Rectangle.TOP_BORDER;
            cell.BorderWidthBottom = 3f;
            tab.AddCell(cell);
            //row 1
            tab.AddCell("R1C1");
            tab.AddCell("R1C2");
            tab.AddCell("R1C3");
            //row 2
            tab.AddCell("R2C1");
            tab.AddCell("R2C2");
            tab.AddCell("R2C3");
            cell = new PdfPCell();
            cell.Colspan = 3;
            iTextSharp.text.List pdfList = new List(List.UNORDERED);
            pdfList.Add(new iTextSharp.text.ListItem(new Phrase("Unorder List 1")));
            pdfList.Add("Unorder List 2");
            pdfList.Add("Unorder List 3");
            pdfList.Add("Unorder List 4");
            cell.AddElement(pdfList);
            tab.AddCell(cell);
            doc.Add(tab);
            doc.Close();
            file.Close();
 
Share this answer
 

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