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 = ; 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的更多相关文章
随机推荐
- ubuntu16.04 npm安装
$ sudo apt-get install python-software-properties $ curl -sL https://deb.nodesource.com/setup_6.x | ...
- 【C++】C++中的流
目录结构: contents structure [-] 1.IO类 IO对象无拷贝状态 条件状态 文件流 文件模式 string流 1.IO类 除了istream和ostream之外,标准库还定义了 ...
- Linksys WRT610n V2 刷ddwrt后安装entware-ng,使用opkg
安装步骤很简单,首先启用usb.jffs.等. 然后: mkdir -p /jffs/opt mount -o bind /jffs/opt /opt wget -O - http://pkg.ent ...
- pom文件中maven-assembly-plugin插件学习
一.使用场景 如果项目是微服务架构,可能用到这个插件的概率比较高,平时普通的项目不需要这样的实现方式. 如果项目内的一部分通用功能,不需要挨个引用,则需要将通用功能部分达成jar包. 二.Maven- ...
- php位运算 与 或 异或 取反
<?php /** php中有4个位运算,分别是&与 |或 ^异或 ~取反 & 两位全为1,结果为1 | 有一位为1,结果为1 ^ 一个为0,一个为1,结果为1 ~ 取反0-&g ...
- 【C语言】 重拾
[C语言] 因为以前学过C语言,只不过太长时间不用,已经忘得差不多了… 所以这篇文章的性质是把C语言中一些对于现在的我不是很符合预期的知识点记录一下. ■ HelloWorld程序 HelloWorl ...
- JSP之连接SQL Server
1.在SQL Server中启用sa(请参考本人博客:http://www.cnblogs.com/zhouhb/archive/2011/02/15/1955324.html)2.在SQL Serv ...
- python3 使用ldap3来作为django认证后台
首先先使用ldap3测试ldap服务是否正常 我们先要拿到dc的数据,以及连接ldap的密码,还有搜索的字段(search_filter), 一般来说search_filter 这个是从负责ldap运 ...
- etl数据同步工具 kettle
kellet使用 https://www.cnblogs.com/gala1021/p/7814712.html
- 【Excel】读取固定长文本
'******************************************************************************* ' 固定長形式テキストファイルを読み込 ...