image to pdf

public void ExportDataIntoPDF(string pathName, String path)
        {//导出至PDF
            iTextSharp.text.Document document = new iTextSharp.text.Document();
            try
            {
                iTextSharp .text .pdf .PdfWriter .GetInstance (document, new FileStream(pathName, FileMode.CreateNew ));
                document.Open();
                iTextSharp.text.pdf.BaseFont bfChinese = iTextSharp.text.pdf.BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font Titlefont = new iTextSharp.text.Font(bfChinese, 16, iTextSharp.text.Font.BOLD , new iTextSharp.text.Color(0, 0, 0));
               
       document.Add(new Paragraph("          将图片转成PDF:" + "\n", Titlefont));
                iTextSharp.text.Image je = iTextSharp.text.Image.GetInstance(path);//path就是函数入参,即你要转成PDF的图片路径
                document.Add(je);
}

            catch (Exception de)
            {
                MessageBox .Show (de.ToString());
            }
            document.Close();
        }
posted @ 2011-04-11 20:21  一个不爱洗澡的鱼  阅读(297)  评论(0编辑  收藏  举报