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的更多相关文章
随机推荐
- 关于海康威视与Unity3d集成冲突问题解决
一.集成 1.1 了解什么是ANSI系列与GNU系列 https://baike.baidu.com/item/ANSI%20C/7657277?fr=aladdin https://ww ...
- Linux下终端录制工具-asciinema
1. 官网 https://asciinema.org/ 2. 功能 录音 录制终端命令 上传到多种位置 3. 使用方法 sudo yum install asciinema # 安装 asciine ...
- PHP-问题处理Fatal error: Uncaught Error: Call to undefined function mb_strlen()
1.问题 今天重新安装了ubuntu,PHP,MySQL,Apache,到测试CMS项目时发生一个错误: Fatal error: Uncaught Error: Call to undefined ...
- appium 报错
2018-11-27 18:05:56:313 - [Logcat] Logcat terminated with code 0, signal null 2018-11-27 18:05:56:31 ...
- extjs ajax 同步 及 confirm 确认提示框问题
//上传文件 uploadModel: function() { if(Ext.getCmp('exup').getForm().isValid()) { var ssn = this.upPanel ...
- java集合 线程安全
1.快速失败(fail-fast)和安全失败(fail-safe)? 一:快速失败(fail—fast) 在用迭代器遍历一个集合对象时,如果遍历过程中对集合对象的内容进行了修改(增加.删除.修改),则 ...
- SparkStreaming+Kafka 处理实时WIFI数据
业务背景 技术选型 Kafka Producer SparkStreaming 接收Kafka数据流 基于Receiver接收数据 直连方式读取kafka数据 Direct连接示例 使用Zookeep ...
- mysql数据字段整理
<?php header('content-type:text/html;charset=utf-8'); define('DB_HOST','127.0.01'); define('DB_US ...
- Spark--sql--所有函数举例(spark-2.x版本)
! expr - Logical not. % expr1 % expr2 - Returns the remainder afterexpr1/expr2. Examples: > SELEC ...
- Ubuntu下pdf和图片互转
前边文章可以将ppt转换为pdf 查看 使用unoconv将ppt转为pdf,再使用imagemagick将pdf转为图片 这次想将pdf和图片进行互转 当前目录下只有2.ppt 1.ppt转pdf ...