zoukankan      html  css  js  c++  java
  • PDF合并

    using System.IO;

    using iTextSharp.text;
    using iTextSharp.text.pdf;

    /// <summary>
            /// PDF合并
            /// </summary>
            /// <param name="fileList">需要合并的PDF文件路径</param>
            /// <param name="outMergeFile">合并保存输出路径</param>
            private void mergePDFFiles(string[] fileList, string outMergeFile)
            {
                PdfReader reader;
                Document document = new Document();
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outMergeFile, FileMode.Create));
                document.Open();
                PdfContentByte cb = writer.DirectContent;
                PdfImportedPage newPage;
                for (int i = 0; i < fileList.Length; i++)
                {
                    if (!File.Exists(fileList[i]))
                        continue;

                    reader = new PdfReader(fileList[i]);
                    int iPageNum = reader.NumberOfPages;
                    for (int j = 1; j <= iPageNum; j++)
                    {
                        document.NewPage();
                        newPage = writer.GetImportedPage(reader, j);
                        cb.AddTemplate(newPage, 0, 0);
                    }
                }
                document.Close();
            }

  • 相关阅读:
    JS 日期加多少天,减多少天
    SQL 触发器
    SGU100
    连续子数组的最大和
    字符串的排列
    二叉搜索树与双向链表
    数组中出现次数超过一半的数字
    复杂链表的复制
    二叉树中和为某一值的路径
    二叉搜索树的后序遍历序列
  • 原文地址:https://www.cnblogs.com/OwenWu/p/1776469.html
Copyright © 2011-2022 走看看