生成pdf的插件工具,绿色插件,请放心使用,C#使用方法:先引用itextsharp.dll动态链接库,然后using itextsharp.text等空间,即可使用。 引用: using iTextSharp; using iTextSharp.text; using iTextSharp.text.pdf; 方法: /// /// 生成pdf格式文件 /// /// pdf文件路径 /// 数据信息 public static void dtWriteFileByPdf(string FilePath, DataTable dt) { try { Document document = new Document() ; PdfWriter.GetInstance(document, new FileStream(FilePath, FileMode.Create)); document.Open(); BaseFont bfChinese = BaseFont.CreateFont(AppDomain.CurrentDomain.BaseDirectory + "SIMSUN.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, new BaseColor(0, 0, 0)); PdfPTable table = new PdfPTable(dt.Columns.Count); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { table.AddCell(new Phrase(dt.Rows[i][j].ToString(), fontChinese)); } } document.Add(table); document.Close(); } catch (DocumentException de) { } } ; PdfWriter.GetInstance(document, new FileStream(FilePath, FileMode.Create)); document.Open(); BaseFont bfChinese = BaseFont.CreateFont(AppDomain.CurrentDomain.BaseDirectory + "SIMSUN.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, new BaseColor(0, 0, 0)); PdfPTable table = new PdfPTable(dt.Columns.Count); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { table.AddCell(new Phrase(dt.Rows[i][j].ToString(), fontChinese)); } } document.Add(table); document.Close(); } catch (DocumentException de) { } }