如何将若干个pdf文件(包括图像和文字)读取后在统一写入一个pdf文件
相当于把若干个pdf文件拼接成一个pdf文件.
相当于把若干个pdf文件拼接成一个pdf文件.
解决方案 »
- 接手的旧项目,帮忙解决struts2 type="json"的问题~
- 谁有基于struts2 可以改pop3的邮件收发的源码啊
- aop实现日志报错No setter found for property 'proxyinterface' in class
- 我想问下关于权限的问题
- 关于SSH框架配置文件如何合理分布
- Spring 使用定时器问题
- 关于jfreechart 高手进来看看 在线等
- 求“精通EJB”配套光盘内容
- struts多模块验证资源文配置问题
- 哪里能找到struts-menu关于权限控制的中文资料?
- 这段代码哪的问题?
- java.lang.NumberFormatException: null 问题
帮你搜了..希望有帮助.http://java-x.blogspot.com/2006/11/merge-pdf-files-with-itext.htmlhttp://www.gnostice.com/nl_article.asp?id=86&t=Merging_And_Splitting_PDF_Documents_Using_PDFOne_Javahttp://www.pdfonline.com/easypdf/sdk/samples/process/merge-pdf/java/java-mergepdf.htm
2 输出即可(代码如下)。import java.awt.Color;
import java.io.FileOutputStream;import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;public class PDFWriter { public Chapter pdfWriter(){
try {
//initial a document
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
//create pdf writer
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("resource\\example.pdf"));
document.open();
//create paragraph object
document.add(new Paragraph("First page of the document!"));
document.add(new Paragraph("Some more text on the first page with different color and font type.",
FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 150, 200))));
//create chapter object
Paragraph title1 = new Paragraph("Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA,
18, Font.BOLDITALIC, new Color(0, 0, 255)));
Chapter chapter1 = new Chapter(title1, 1);
chapter1.setNumberDepth(0);
//create section object
Paragraph title11 = new Paragraph("This is Section 1 in Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA, 16,
Font.BOLD, new Color(255, 0, 0)));
Section section1 = chapter1.addSection(title11);
Paragraph someSectionText = new Paragraph("This text comes as part of section 1 of chapter 1.");
section1.add(someSectionText);
someSectionText = new Paragraph("Following is a 3 X 2 table.");
section1.add(someSectionText);
//create a table object
Table table = new Table(3,2);
table.setBorderColor(new Color(220, 255, 100));
table.setPadding(5);
table.setSpacing(5);
table.setBorderWidth(1);
Cell header1 = new Cell("yao");
header1.setHeader(true);
table.addCell(header1);
Cell header2 = new Cell("tibco");
header2.setHeader(true);
table.addCell(header2);
Cell header3 = new Cell("monkey");
header3.setHeader(true);
table.addCell(header3);
table.endHeaders();
table.addCell("1.1");
table.addCell("1.2");
table.addCell("1.3");
section1.add(table);
//create list object
List list = new List(true, false, 10);
list.add(new ListItem("First item"));
list.add(new ListItem("Second item"));
section1.add(list);
document.add(chapter1);
//close document
document.close();
return chapter1;
} catch (Exception e) {
System.out.println("file output error!");
e.printStackTrace();
return null;
}
}
public static void main(String[] args){
PDFWriter writer = new PDFWriter();
writer.pdfWriter();
}
}