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 = ; i < fileList.Length; i++)
{
if (!string.IsNullOrEmpty(fileList[i]))
{
PdfReader reader = new PdfReader(fileList[i]);
int iPageNum = reader.NumberOfPages;
for (int j = ; j <= iPageNum; j++)
{
document.NewPage();
newPage = writer.GetImportedPage(reader, j);
cb.AddTemplate(newPage, , );
}
readerList.Add(reader);
}
}
document.Close();
//释放集合资源
foreach (var rd in readerList)
{
rd.Close();
}
}
}

iTextSharpH的更多相关文章

随机推荐

  1. 生成命令行接口--google开源的fire使用体验【python-fire】

    在python中,命令行接口常用的argparse 和click,但是相对于python-fire 来说灵活度太缺了,fire可以直接将python中的函数,以命令行显示. 简单的介绍几个例子: #! ...

  2. Google I/O 官方应用中的动效设计

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jILRvRTrc/article/details/82881743 作者:Nick Butcher, ...

  3. Python Every Class Needs a __repr__

    一.思考 当我们在Python中定义一个类的时候,如果我们通过print打印这个类的实例化对象,或者我们直接输入这个类实例化对象会返回怎么样的结果,如下代码: >>> class P ...

  4. nginx伪静态配置教程总结

    在nginx中配置伪静态,也就是常说的url重写功能,只需在nginx.conf配置文件中写入重写规则即可. 当然,这个规则是需要熟悉正则表达式,只掌握nginx自身的正则匹配模式即可,对正则不了解的 ...

  5. 【翻译】Nginx的HTTP负载均衡

    本文为翻译文,原文地址:http://nginx.org/en/docs/http/load_balancing.html 介绍 将请求负载均衡到多个应用实例是一个常用的技术,它起到优化资源使用率.最 ...

  6. centos 7 下的 service部署

    在centos 7下部署service一般涉及到jar包部署, service脚本. 数据存贮路径, log存贮路径 jar包部署 /usr/local/app/app1/app1.jar servi ...

  7. 北京Java笔试题整理

    北京Java笔试题整理 1.什么是java虚拟机?为什么ava被称作是"平台无关的编程语言? 答:Java虚拟机可以理解为一个特殊的"操作系统",只是它连接的不是硬件,而 ...

  8. OpenCV + python 实现人脸检测(基于照片和视频进行检测)

    OpenCV + python 实现人脸检测(基于照片和视频进行检测) Haar-like 通俗的来讲,就是作为人脸特征即可. Haar特征值反映了图像的灰度变化情况.例如:脸部的一些特征能由矩形特征 ...

  9. php -- new self() 和 new static

    看一段摘自网上的代码 class A { public static function get_self() { return new self(); } public static function ...

  10. 【netcore基础】ubuntu 16.04 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动

    今天来整理下 netcore 在 linux(ubuntu) 上的运行环境搭建 对应版本 ubuntu 16.04 .net core 2.1 nginx version: nginx/1.10.3 ...