• 图片转pdf


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

                try
                {
                    iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(newpdf, FileMode.Create, FileAccess.ReadWrite));

                    document.Open();
                    iTextSharp.text.Image image;
                    for (int i = 0; i < files.Length; i++)
                    {
                        image = iTextSharp.text.Image.GetInstance(files[i]);
                    
                        if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
                        {
                            image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                        }
                        else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
                        {
                            image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                        }
                        image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
                        //image.SetDpi(72, 72);

                        document.NewPage();
                        document.Add(image);
                    
                        //Phrase phrase3 = new Phrase("dreign@163.com\n", FontFactory.GetFont(FontFactory.TIMES, 9, iTextSharp.text.Font.NORMAL, new iTextSharp.text.Color(192, 192, 192)));
                        //document.Add(phrase3);
                    }
                }
                catch (Exception ioe)
                {
                    MessageBox.Show(ioe.Message);
                }
                document.Close();
            }

  • 相关阅读:
    【基础】Oracle基础2
    【基础】Oracle基础1
    【基础】ORACLE中on commit preserve rows和 on commit delete rows的区别
    【函数】ORACLE中MULTISET 的用法
    【基础】ORACLE中的spool 命令
    【基础】ORACLE中substr的用法
    【练习】mysql源码安装
    关于并行执行(parallel executing)的认识
    关于DRM的理解
    打印Excel文件时如何不显示页眉和页脚
  • 原文地址:https://www.cnblogs.com/itecho/p/2486484.html
Copyright © 2020-2023  润新知