如何使用itextshap创建PDF [英] How to create PDF using itextshap

查看:197
本文介绍了如何使用itextshap创建PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......



是否有人使用iTextshap从sql数据库中获取数据?我在线寻找解决方案,但没有运气......



如果您有代码,请随时发布或发布链接



请请帮助....

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....

推荐答案

看一下这个



Create-PDF-report-from-database-in-ASPNet-using-C-and-VBNet.aspx [ ^ ]


尝试

使用iTextSharp创建PDF文档 [ ^ ]

使用ItextSharp在C#中使用页脚生成PDF [ ^ ]



对于ASP.Net - http ://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp [ ^ ]
Try
Creating PDF documents with iTextSharp[^]
Generating PDF using ItextSharp with Footer in C#[^]

For ASP.Net - http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp[^]


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();


这篇关于如何使用itextshap创建PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆