IText实现多个pdf转成一个pdf
来源:互联网 发布:数据采集与处理投稿 编辑:程序博客网 时间:2024/05/17 18:14
package com.pdf;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfCopy;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
public class PdfOperate {
public static void main(String[] args) {
String[] files = { "G:/abc/1.pdf", "G:/abc/2.pdf" , "G:/abc/3.pdf", "G:/abc/4.pdf"};
String savepath = "G:/test3.pdf";
morePdfTopdf(files, savepath);
}
public static void morePdfTopdf(String[] files, String savepath) {
Document document = null;
try {
document = new Document(new PdfReader(files[0]).getPageSize(1));
PdfCopy copy = new PdfCopy(document, new FileOutputStream(savepath));
document.open();
for (int i = 0; i < files.length; i++) {
PdfReader reader = new PdfReader(files[i]);
int n = reader.getNumberOfPages();//获得总页码
for (int j = 1; j <= n; j++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, j);//从当前Pdf,获取第j页
copy.addPage(page);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}finally{
if(document != null){
document.close();
}
}
}
}
引自:http://wangming2012.iteye.com/blog/1529912
- IText实现多个pdf转成一个pdf
- itext 将html转成pdf
- itext实现pdf导出
- iText实现pdf导出
- 用iText把图片转成PDF
- 使用iText把html转成pdf
- 打印pdf itext 的多个pdf合并并删除旧的pdf文件
- iText导出PDF经典实现
- iText 实现 html 转换 pdf
- Itext实现pdf文件Encryption
- iText导出PDF经典实现
- iText导出PDF经典实现
- iText导出PDF经典实现
- iText实现html转pdf
- iText导出PDF经典实现
- itext生成pdf代码实现
- 导出PDF (iText实现) PdfDownloadDS
- java多个pdf合成一个pdf
- 自定义 Dialog
- 电子游戏的秘密:雅达利和它的 PONG
- C++ CLR 读取Worksheet名称
- android 知识点 之Provider
- Python-字符串操作方法(转)
- IText实现多个pdf转成一个pdf
- 让我恍然大悟的Mysql高效率分页方法
- 排序之直接插入排序
- Python中re(正则表达式)模块学习
- [转载]炒股其实是一种博弈
- 今天打到sxm一段,有点井漏,从上午10点半到现在一直在堵漏
- vmware accelerated amd pcnet adapter显示黄色感叹号
- wifi.p2p
- splitex.h