增加PDF元件[itextsharp]到C#專案並測試使用完整步驟紀錄
增加PDF元件[itextsharp]到C#專案並測試使用完整步驟紀錄
資料來源:https://www.youtube.com/watch?v=e1uMdAG8L3Y
00.去GOOGLE 搜尋itextsharp 並且下載
01.解壓 itextsharp-dll-core.zip
iTextSharp.xml
itextsharp.dll
02.解壓 itextsharp-dll-pdfa.zip
itextsharp.pdfa.dll
03.解壓 itextsharp-dll-xtra.zip
itextsharp.xtra.dll
04.專案引入三個DLL參考
05.在程式碼中加入引用函式庫語法
//PDF_start
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
//PDF_end
06.建立一個按鈕事件並加入測試程式碼
private void button1_Click(object sender, EventArgs e)
{
iTextSharp.text.Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 42, 35);//左,右,上,下 邊界
iTextSharp.text.pdf.PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(“test.pdf”, FileMode.Create));
doc.Open();
Paragraph paragraph = new Paragraph(“this is my first line.”);
doc.Add(paragraph);
doc.Close();
}