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

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 11 的頭像
    11

    冠霖的部落格

    11 發表在 痞客邦 留言(0) 人氣()