Beispiel #1
0
        private static void Method()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("name", typeof(string));
            dt.Columns.Add("age", typeof(int));
            dt.Columns.Add("address", typeof(string));
            dt.Clear();
            DataRow dr = dt.NewRow();

            dr["id"] = 1; dr["name"] = "cscc"; dr["age"] = 26; dr["address"] = "江西省";
            dt.Rows.Add(dr);
            dt.AcceptChanges();
            bool b = ITextSharpHelper2.ConvertDataTableToPDF(dt, @"C:\Users\Administrator\Desktop\testPDF.pdf", "C://WINDOWS//FONTS//SIMSUN.TTC,1", 9);

            Console.WriteLine($"{b}");
            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            #region  DataTable 转成pdf文件

            // Method();
            #endregion

            #region 向pdf文件添加图片

            //ITextSharpHelper2.AddImg(@"C:\Users\Administrator\Desktop\testPDF.pdf", @"C:\Users\Administrator\Desktop\tempPDF.pdf", @"C:\Users\Administrator\Desktop\QRCode.png", 300, 100);

            #endregion

            #region 向pdf模板文件添加数据

            ITextSharpHelper2.AddNewPdf(@"C:\Users\Administrator\Desktop\temp3.pdf", @"C:\Users\Administrator\Desktop\temp123.pdf");
            #endregion

            Console.ReadKey();
        }