iTextSharp - 建立PDF文件

iTextSharp - 建立PDF文件

using iTextSharp.text;
using iTextSharp.text.pdf;
...
private void button1_Click(object sender, EventArgs e)
{           
 Document document = new Document(PageSize.A4);
 try {                
	 PdfWriter.GetInstance(document, new FileStream("demo.pdf",	FileMode.Create));                
	 document.Open();
	 BaseFont gothicbf = BaseFont.CreateFont(
	                             "c:\\windows\\fonts\\mingliu.ttc,0",
	                             BaseFont.IDENTITY_H,
	                             BaseFont.EMBEDDED
	                             );
	 iTextSharp.text.Font gothicfont = new iTextSharp.text.Font(gothicbf, 16, 0);                    
	 String textg = "這是一個PDF測試頁(細明體)\n此為參考iTextSharp Version=4.0.7.0製作";
	 document.Add(new Paragraph(textg, gothicfont));                
 }
 catch (DocumentException de) {
     ...
 }
 catch (IOException ioe) {
     ... 
 }
 finally {
     document.Close(); 
     ...
 }
}