zoukankan      html  css  js  c++  java
  • iTextSharpH

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using System.IO;
    
    
    public class iTextSharpH
    {
        /// <summary> 合并PDF </summary>
        /// <param name="fileList">PDF文件集合</param>
        /// <param name="outMergeFile">合并文件名</param>
        public static void MergePDFFiles(string[] fileList, string outMergeFile)
        {
            List<PdfReader> readerList = new List<PdfReader>();//记录合并PDF集合
            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 (!string.IsNullOrEmpty(fileList[i]))
                {
                    PdfReader 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);
                    }
                    readerList.Add(reader);
                }
            }
            document.Close();
            //释放集合资源
            foreach (var rd in readerList)
            {
                rd.Close();
            }
        }
    }
  • 相关阅读:
    C. Chessboard( Educational Codeforces Round 41 (Rated for Div. 2))
    B. Lecture Sleep( Educational Codeforces Round 41 (Rated for Div. 2))
    51Nod 1256 乘法逆元(扩展欧几里得)
    C
    B
    9.13 web基础知识
    web基础知识
    9.11 web基础知识
    9.10 web基础知识
    web 基础知识
  • 原文地址:https://www.cnblogs.com/lee2011/p/9355149.html
Copyright © 2011-2022 走看看