特色栏目

ASP源码

PHP源码

.NET源码

JSP源码

游戏频道
专题合集
关闭菜单
首页> ASP.NET教程> 生成pdf文件的好东西,itextsharp

生成pdf文件的好东西,itextsharp

时间:2009-07-01 16:25:31 作者:互联网

官网:
http://sourceforge.net/projects/itextsharp/
http://hardrock.cnblogs.com/
http://www.rubypdf.com/

现在的版本是3.18版,记得在引用里导入itextsharp.下面的代码是把图象合并到一个多页pdf的例子.

      private void process(string[] files, string newpdf)
        {
             iT***Sharp.text.Document document = new iT***Sharp.text.Document(iT***Sharp.text.PageSize.A4, 25, 25, 25, 25);

            try
            {
                iT***Sharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(newpdf, Fi***ode.Create, Fi***ccess.ReadWrite));

                do***ent.Open();
                iT***Sharp.text.Image image;
                for (int i = 0; i < fi***.Length; i++)
                {
                    image = iT***Sharp.text.Image.GetInstance(files[i]);
                
                    if (im***.Height > iT***Sharp.text.PageSize.A4.Height - 25)
                    {
                        im***.ScaleToFit(iT***Sharp.text.PageSize.A4.Width - 25, iT***Sharp.text.PageSize.A4.Height - 25);
                    }
                    else if (im***.Width > iT***Sharp.text.PageSize.A4.Width - 25)
                    {
                        im***.ScaleToFit(iT***Sharp.text.PageSize.A4.Width - 25, iT***Sharp.text.PageSize.A4.Height - 25);
                    }
                    im***.Alignment = iT***Sharp.text.Image.ALIGN_MIDDLE;
                    //***ge.SetDpi(72, 72);

                    do***ent.NewPage();
                    do***ent.Add(image);
                
                    //Phrase phrase3 = new Phrase("ma***o:dr***[email protected]n">dr***[email protected]n", Fo***actory.GetFont(Fo***actory.TIMES, 9, iT***Sharp.text.Font.NORMAL, new iT***Sharp.text.Color(192, 192, 192)));
                    //do***ent.Add(phrase3);
                }
            }
            catch (Exception ioe)
            {
                Me***geBox.Show(io***essage);
            }
            do***ent.Close();
        }

相关文章 最新文章

相关应用

热门文章

猜你喜欢

返回顶部