//字體設定,c:\windows\fonts\kaiu.ttf,中文楷體
BaseFont bfchinese = BaseFont.CreateFont(@"c:\windows\fonts\kaiu.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font ChFont = new Font(bfchinese, 12);
Font ChFont_blue = new Font(bfchinese, 40, Font.NORMAL, new BaseColor(51, 0, 153));
Font ChFont_msg = new Font(bfchinese, 12, Font.ITALIC, BaseColor.RED);
string filename =HttpRuntime.AppDomainAppPath+"pdf/"+DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
Document document = new Document(PageSize.A4.Rotate());
PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
//加密
//pdfWriter.SetEncryption(PdfWriter.STRENGTH128BITS, "1234", "1244", PdfWriter.ALLOW_COPY | PdfWriter.AllowPrinting);
document.Open();
document.AddAuthor("zero");
document.Add(new Paragraph("放大是否颯颯的",ChFont_blue));//調用重載函數 public Paragraph(string str, Font font);將字體傳進去
Image img = Image.GetInstance(HttpRuntime.AppDomainAppPath + "img/1.jpg");
document.Add(img);
//Header footer = new Header();
document.AddHeader("footer", "this is footer");
//pdfWriter.Dispose();
//pdfWriter.Close();
document.Dispose();
document.Close();
context.Response.Write(filename);